Professional Documents
Culture Documents
Project Title: Led Dice Project Description: in This Project, 7 Leds Are Connected To Portb of A Pic Microcontroller
Project Title: Led Dice Project Description: in This Project, 7 Leds Are Connected To Portb of A Pic Microcontroller
Project Title: Led Dice Project Description: in This Project, 7 Leds Are Connected To Portb of A Pic Microcontroller
Project description: In this project, 7 LEDs are connected to PORTB of a PIC microcontroller
and arranged such that they can show the faces of a dice when lit. Also a
push-button switch is connected to bit 7 of PORTB using a pull-up resistor.
When the switch is pressed the LEDs are lit randomly to show a dice
number between 1 and 6. Figure 5.35 shows the LEDs lit for a given dice
number.
Flow diagram: The flow diagram of the project is shown in Figure 5.38. At the beginning
of the program the I/O direction is specified. When the switch is pressed
a random number generation is simulated between 1 and 6 and this number
is then displayed on the LEDs which are constructed similar to the
face of a real dice.
Required number and LED to be turned on
Required number LEDs to be turned on
1 D4
2 D2, D6
3 D2, D4, D6
4 D1, D3, D5, D7
5 D1, D3, D4, D5, D7
6 D1, D2, D3, D5, D6, D7
LED DICE
========
7 LEDs are connected to PORTB of a PIC microcontroller and arranged as in the faces
of a dice. Also, a push-button switch is connected to bit 7 of PORTB.
When the switch is pressed the program generates a dice number
between 1 and 6 and turns on the appropriate LEDs to imitate the faces
of a real dice. The LEDs are turned on for 5 seconds and after this time
they are cleared and the program is ready to accept a new push-button
action.
DEFINITIONS
LEDS VAR BYTE
AGAIN:
DICE = 1
NEWNO:
Find the LEDs to be turned on. DICE is between 1 and 6. LEDS is the data
LOOKUP DICE, [0, $08, $22, $2A, $55, $5D, $77], LEDS