Now that you know how to make the lights flash we can have some fun. Try to create the following (Please have a go at the exercises yourself before looking at my code)!:

1. Try to duplicate the display at level crossings. The LED on PORTA BIT 0 should be lit while the one on bit 1 should be off, and vice versa. To do this you will need to set both bits as outputs and reverse the state on each flash.
   [Exercise 1.5 (ex15.c)]

2. At the moment the mark space ratio of on and off is equal. Modify the program so that the LED pulses rather than flashes. (To do this you must change the values in the for loops)
   [Exercise 1.6 (ex16.c)]

3. We have written the delay as a for loop which is repeated twice in the program. See if you can rewrite the program so that we have a function called delay which we can call to make a delay of a particular size. Make the function accept a parameter which is the size of the delay we require.
   [Exercise 1.7 (ex17.c)]

4. This is the final one. I want you to change the program so that the flashing speed changes as the program runs. To do this you will need to use another variable (perhaps called speed) which is used to control the size of the delay. Each time you flash the LED you change the value in speed so that the next flash is a different length. Be careful that you don't let the speed value get too small, or your LED will stop flashing and just glow! (For real style write a program which makes the flash speed up and slow down again - to do this you will need to keep track whether you are counting up or counting down and change the timer value appropriately.
   [Exercise 1.8 (ex18.c)]