jhave_21:
So the sketch will perform these multitasking operations:
Led1 will blink (500 milliseconds) continuosly and Led2 will turn on only if the button is pressed, and even I'm pressing the button the Led1 is still blinking?
any Ideas?
thanks
Apart from what the others have said, why should led1 stop blinking just because led2 is on?
What you have is this:
toggle led1 (if it's time to do so)
read button
if button pressed, led2 on
if button not pressed, led2 off
loop to top
There's nothing in the turning off of led 2 that explicitly prevents the toggling of led1.
What you need is this:
read button
if button is not pressed, toggle led1 (if it's time to do so) and off led 2
if button is pressed, on led2, and perhaps restore led1 to a default on or off state
loop to top