Make a copy of program 2.1 and modify it so that the light goes off when
the button is not pressed. Your new program should be exactly
the same size as the original.
[Exercise 2.6 (ex26.c)]
Make a copy of program 2.2 and fix it so that if both buttons are held
down the light goes out rather than flickers. I suggest that you look
at performing a third test which uses a logical && operation to
see if both buttons are down and then turns the light off if they are.
Remember that if you do this you don't want to look to see if either of
the buttons are down as well, otherwise they will still flash! You can
ensure that statements are not performed by using the else addition to
an if construction or you may find a use for the continue.
[Exercise 2.7 (ex27.c)]
Make a copy of program 2.5 and change it so that the light does not go
off if the button is held down. You should be able to get this effect
by making the program smaller! (you might find it useful to make
the time out period smaller when you are testing the program)
[Exercise 2.8 (ex28.c)]
Create a new program which implements a "coin tosser". The
program will flash a LED very quickly while a button is held down. When
the button is released the flashing will stop and the led will be lit
or not lit with a 50/50 probability. Do you think you need to worry about
debouncing the signal in this case?
[Exercise 2.9 (ex29.c)]