Hello!
i want to start and stop my program (blinking leds) with the Virtual Button V0. Stop means all Leds are off.
I start the loop with V0 but when i press the button to turned off the lights, the while loop continues and wont stop. it also donnot work with if…else
how do i get out of the loop and stop my program?
BLYNK_WRITE(V0)
{
int pinValue = param.asInt();
while(pinValue==1){
for (int j = 0; j < fade_cycles; j++) {
for (int i = 0; i < NR_OF_LIGHTS; i++) {
fadingLight(i);
delay(fade_delay);
}}
}
It’s difficult to say without seeing the rest of your code and knowing what values you’re using for:
fade_cycles
NR_OF_LIGHTS
fade_delay
but clearly these two For/Next loops need to complete before the value of V0 can be checked again and the Else statement executed.
It’s also possible (likely even?) that you’re dropping your Blynk connection while these loops are running and that you’re having to wait until it reconnects and your switch is in the Off position before the Else code can execute.