I am trying to blink two LED's, starting at slow rate then increasing to fast s follows: 1 on, 1&2 on, 2 on, 1&2 on, 1 on, etc. The blinks go through the loop twice then speed up and repeat until both are on continuously. Then I want LED's 3 & 4 to come on. I got the 1 & 2 LED's to blink as I want but anything I put following my for / if loop goes into the loop. This works for blinking the 1 & 2 LED's:
int led1 = 9;
int led2 = 10;
int led3 = 11;
int led4 = 12;
int delay1 = 700;
int delayAmount1 = delay1 / 10;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
void loop() {{
delay1 = delay1 - delayAmount1;
for (int i=0 ; i <2 ; i++) {
if (delay1 > 10)
digitalWrite(led1, HIGH); //yellow on (yellow)
delay(delay1);
digitalWrite(led2, HIGH); //red and yellow on (orange)
delay(delay1);
digitalWrite(led1, LOW); //yellow off (red)
delay(delay1);
digitalWrite(led1, HIGH); //yellow on (orange)
delay(delay1);
digitalWrite(led2, LOW); //red off (yellow)
digitalWrite (led1, LOW); //yellow off (all off)
}
}
// digitalWrite(led3, HIGH); //blue on
//delay(1000);
//digitalWrite(led4, HIGH); //green on
}
If I remove the // from
// digitalWrite(led3, HIGH); //blue on
//delay(1000);
//digitalWrite(led4, HIGH); //green on
they become part of the loop. Can someone tell me what I am doing wrong? Kind of new to this.
if (delay1 > 10)– MichaelT Mar 09 '19 at 21:25