Circuit Diagram: LED Dice using Microcontroller
The circuit diagram for LED Dice using microcontroller project is shown in the figure below.
Bit 0 of port 3 is generally held at logic HIGH with pull-up resistor R3=100K. when switch S1 is pressed, bit 0 of port 3 moves to logic LOW and is detected by the microcontroller. As shown in circuit diagram all the seven LEDs are so mounted that they will show dots for different numbers as in real dice.
The different patterns for different numbers are shown below:
Program Description
A random dice number is obtained during scanning of the push-button switch as follows. The program scans the push-button switch continuously. If the switch is not pressed (i.e. at logic HIGH), a number is incremented between 1 and 6. Whether the push-button is pressed, the current value of the number is read and this value is used as the new dice number. Since the switch is pressed by the user in random, the numbers generated are also random numbers from 1 to 6. The new random number is displayed on the seven LEDs appropriately. After about 2 seconds delay, all LEDs are turned off and the above process is repeated forever.
Download
Click here to download .C and .HEX file for this project.
If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!