LED Dice using Microcontroller (8051): Electronics Project

In this project, we are going to build a LED Dice using microcontroller. We have already seen many microcontroller project, you can check all the previous project here. This project is used to simulate dice, which displays a random number from 1 to 6 by using 6 LEDs connected to port 1 of the microcontroller. Pin no 2 (or bit 0 of port 3 (P3.0)) is used as the input and a push-button switch is connected to this pin. Every time, when we press this switch, a new number is displayed.

Circuit Diagram: LED Dice using Microcontroller


The circuit diagram for LED Dice using microcontroller project is shown in the figure below.






[caption id="" align="aligncenter" width="490"]LED dice using AT89C2051 microcontroller Electronics mini project LED dice using microcontroller[/caption]











[caption id="" align="aligncenter" width="490"]LED dice using AT89C2051 microcontroller LED dice using AT89C2051 microcontroller[/caption]













[caption id="" align="aligncenter" width="490"]LED dice using AT89C2051 microcontroller LED dice using AT89C2051 microcontroller[/caption]





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:






[caption id="" align="alignnone" width="490"]LED dice using microcontroller LED dice using microcontroller[/caption]






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!