Hi everyone. I'm trying to get some code working that decrements from 500 to 1 inside the delay function after turning on and led. The code works fine when i'm incrementing but when decrementing it doesn't run or it runs very slow. I've never encountered something like this, is there anything i'm missing? Thanks in advanced. The idea is to gradually increase the frequency of the LED's until they're flickering so fast they appear to be on.
You debug things with problems by putting serial.Print() in the loop.
For instance:
serial.PRintln('beginning for loop");
for(delayTime = 500; delayTime >= 1; delayTime--){
serial.PRint(delayTime);
led1();
serialPrint("delayTime/scaler", delayTime/scaler);
delay(delayTime/scaler);
led2();
delay(delayTime/scaler);
}
`
Turn the IDE monitor on and see what values you are generating.
It does count down but EXTREMELY slow. It took this around 30 seconds. Whereas counting forward it goes at the normal speed.
begin for loop
for loop control variable: 500
delayTime/scaler: 500
for loop control variable: 499
delayTime/scaler: 499
for loop control variable: 498
delayTime/scaler: 498
for loop control variable: 497
delayTime/scaler: 497
for loop control variable: 496
delayTime/scaler: 496
for loop control variable: 495
delayTime/scaler: 495