when i call BreathingLight2(),use delay
void BreathingLight2()
{
for (int a=0;a<=255;a++)
{
analogWrite(LED2,a);
analogWrite(LED3,a);
delay(140);
}
for (int a=255;a>=0;a--)
{
analogWrite(LED2,a);
analogWrite(LED3,a);
delay(140);
}
}
but i need when something happen(IRremote receive command),stop delay right now,please help me.
Check out the "blink without delay" example. It shows you how you can give up using delay() so you can do two things at once like you are.
but,if you have more function,like for(..) and for(.) and for(),how write this code?
Arrch
4
eagleflydotnet:
but,if you have more function,like for(..) and for(.) and for(),how write this code?
The for loop initializes a value, checks a condition and increments a value. All of that you can do yourself.
system
5
All of that you can do yourself.
You can also add checking inside the for loop, and break; or return; if the condition is true. Change
delay(140);
to
for(int j=0; j<140; j++)
{
delay(1);
// See if it's time to bail
if(timeToBail)
return;
}
Where the comment "See if it's time to bail" is, you'd check for the IR receiver having received something.