// For: https://forum.arduino.cc/t/missing-something-in-my-if-condition-code/1030094
//
// I am not 100% sure what it should do, so I made my own variation:
// The white leds blinks with 500 ms delay.
// The red leds blink together with the white led every fifth time.
const int whiteLedPin = 2;
const int redLedPin = 4;
const int t = 500;
int c = 0;
void setup()
{
Serial.begin(115200);
pinMode(whiteLedPin, OUTPUT);
pinMode(redLedPin, OUTPUT);
}
void loop()
{
Serial.print(c);
if (c == 4) // 0,1,2,3 are normal, 4 is the fifth is special
{
digitalWrite(whiteLedPin, HIGH);
digitalWrite(redLedPin, HIGH);
delay(t);
digitalWrite(whiteLedPin, LOW);
digitalWrite(redLedPin, LOW);
delay(t);
Serial.println();
c = 0; // reset the variable
}
else
{
digitalWrite(whiteLedPin, HIGH);
delay(t);
digitalWrite(whiteLedPin, LOW);
delay(t);
c = c + 1;
}
}