9.4 PROJECT 9.4 – Wheel of Lucky Day

9.4.1 Project Description

In this project, 7 LEDs are connected to PORT C of a PIC microcontroller. In addition, a push-button switch (START) is connected to bit 7 of PORT C. The LEDs are numbered with the days of the week, as shown in Figure 9.21. When the project is started, the LEDs are turned ON and OFF very fast in a rotating manner, such that it is not possible to see which LED is ON at any time. Pressing the button stops the rotation and only the last LED, which was ON at the time, remains lit. The day corresponding to this number is your lucky day of the week.

Figure 9.21 Wheel of lucky day

img

9.4.2 Block Diagram

The block diagram of the project is shown in Figure 9.22.

Figure 9.22 Block diagram of the project

img

9.4.3 Circuit Diagram

In general, a push-button switch can be connected to microcontroller I/O pins using two methods: Active Low and Active High.

The Active Low connection is shown in Figure 9.23. When the switch is not pressed, the input pin of the microcontroller is at logic HIGH. Pressing the switch pulls down this pin to logic LOW and this change of state can be determined by the program.

Figure 9.23 Active Low switch connection

The Active High connection is shown in Figure 9.24. Here, when the switch is not connected, the ...

Get Using LEDs, LCDs and GLCDs in Microcontroller Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.