For loop not incrementing - Led Strip

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. :cold_sweat:

No it isn't updating, it is updating after/before the loop (depending how you look at it).

--> start program

  1. currentmillis = millis();
  2. 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 ...
  3. currentmillis = millis();
  4. do the for loop
    4.1 ..
    4.2 ..
  5. 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