You are on page 1of 1

The code for Task 3 as seen above had the effect of lighting up the LED's in sequence from LED

1 to LED 8 then start again from LED 1, with only one LED on at any time. The code ran as expected, with the desired rotating light effect.

In the program, we used an array LED_LookupTable to store the location of the LED pins that we wish to use. A simple while loop is used to iterate through the array, picking one LED to light up at a time. Once the last LED has been reached, the array index is set back to 0 to start again from LED 1.

A different method of setting the LED pins HIGH was used, compared to the method used in task one. In task one, we used LATDbits.LATD7 = 1 to set pin 7 to HIGH, whereas we have now used LATD = 0x40 to achieve the same effect. This method is more concise and easier to use, especially in the case of using variables or an array of variables (as in our case) to select which pins to activate.

You might also like