The idea was to have two LEDs, one is flashing all the time and the other one joins in as long as a switch is pressed. The LEDs then flash alternating. The hardware is very straight forward.
The first program is rather straight forward. It basically consists of two different loop. One loop is used when the switch is not pressed, the other loop is used when the switch is pressed. The main disadvantage is that the program doesn’t look at the switch when it is processing the second loop. In fact much of the time of the first loop it isn’t looking either. In this case the delay isn’t very long, but if it was it could take quite some time before the program would notice that the switch is actually pressed.
Visit Here for more.