1
2
3
4
5const int pinAC = A1;
6const int potInterval = A2;
7const int potLenght = A3;
8const int potDelay = A4;
9const int outPinTriac = 12;
10const int outPinLED = 13;
11const int inButton = 2;
12int i = 0;
13
14void setup() {
15 pinMode(pinAC, INPUT);
16 pinMode(potInterval, INPUT);
17 pinMode(outPinTriac, OUTPUT);
18 pinMode(outPinLED, OUTPUT);
19 pinMode(inButton, INPUT);
20 digitalWrite(outPinTriac, LOW);
21 digitalWrite(outPinLED, LOW);
22}
23
24void loop() {
25 while (analogRead(pinAC) < 15){}
26 if (digitalRead(inButton) == HIGH) {
27 fire();
28 while (digitalRead(inButton) == HIGH) {}
29 }
30 i = i + 1;
31 if ((i >= map(analogRead(potInterval),0,1020,50,0)) && (analogRead(potInterval) > 10)){
32 fire();
33 i = 0;
34 }
35 if (i > 0){
36 while (analogRead(pinAC)>15){}
37 }
38}
39
40void fire() {
41 for (int ii=0; ii<map(analogRead(potLenght),0,1020,25,1); ii++) {
42 delayMicroseconds(map(analogRead(potDelay),0,1020,0,9000));
43 digitalWrite(outPinTriac, HIGH);
44 digitalWrite(outPinLED, HIGH);
45 delay(1);
46 digitalWrite(outPinTriac, LOW);
47 while (analogRead(pinAC) > 15){}
48 digitalWrite(outPinLED, LOW);
49 while (analogRead(pinAC) < 15){}
50
51 }
52}
jblock41
8 months ago
Interesting. I wonder if the oscillator and voltage control could be applied in module synthesis? Being able to adjust voltage and trigger timing are key.