Hi!
I have a simple timing loop that prints the numbers 1-12 every 250ms then starts over. Perfect. But when I add the last three commented out lines of an If statement the loop just stops at three. Why is that?
Thank you so much.
int i = 0;
unsigned long previousMillis = 0;
const long interval = 250;
void setup() {
Serial.begin(9600);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (i >= 12) {
i = 1;
}
else {
i = i + 1;
}
Serial.println(i);
//if (i = 2) {
// Serial.print("even");
//}
}
}