JamieDemos:
Hi TolpuddleSartre,See the attached screenshot of the serial monitor, each time 1000ms passes i remains at 0.
Hi Speklap
From the screenshot you can see currentMillis is indeed updating.
Regardless I did try moving the unsigned long currentMillis = millis();
around in the program however this did not help.Thanks for the input guys.
Still trying to figure this out.
No it isn't updating, it is updating after/before the loop (depending how you look at it).
--> start program
- currentmillis = millis();
- do the for loop
2.1 if current - previous > interfal -> current = previous
2.2 if statement always false
2.3 if statement always false
2.4 ... - currentmillis = millis();
- do the for loop
4.1 ..
4.2 .. - currentmillis = millis();
The arduino goes through the for loop in a few microseconds. And never updates in those microseconds. So only when i == 0, currentMillis can be bigger than previousMillis + interval