9.5 PROJECT 9.5 – Random Flashing LEDs
9.5.1 Project Description
In this project, 8 LEDs are connected to PORT C of a PIC microcontroller, as in Project 2. The LEDs turn ON and OFF randomly, with 500 ms interval between each output.
9.5.2 Block Diagram
The block diagram of the project is as shown in Figure 9.12.
9.5.3 Circuit Diagram
The circuit diagram of the project is as shown in Figure 9.13.
9.5.4 Project PDL
The PDL of this project is very simple and is given in Figure 9.30.
Figure 9.30 PDL of the project
9.5.5 Project Program
The program is named LED9.C and the program listing of the project is shown in Figure 9.31. In this program, a pseudorandom number generator (Gerhard's generator) function called RandomNumber is used to generate an integer random number between 1 and 255. This number is then sent to PORT C of the microcontroller every 500 ms. The LEDs flash randomly, giving nice patterns of display. The random number generator function requires a seed and the maximum number to be generated as its arguments.
Figure 9.31 Program listing of the project
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access