Introduction: Electronic Dice Using Arduino
We all are familiar with dice and often played LUDO or Snake & Ladders game by using a dice. Dice is cube which contains 6 different numbers from 1 to 6 on all of its sides. We throw dice on a surface to get a random number while playing the games. In this project we have tried to replicate it with a digital dice using Arduino Uno board. In place of throwing the dice, here we need to press a button to get a random number between 0 to 6.
Step 1: Component Required:
- Arduino UNO
- LED's*7
- Pushbuttons *2
- Connecting wires
- Breadboard
- 1 k & 220 ohms resistor
- Power supply
- Buzzer
Step 2: Circuit Diagram:
At the beginning of the program, I/O pins 2 to 9 are configured as digital outputs and pin 9 & 12 is configured as a digital input with an internal pull-up resistor. The program waits until the button is pressed. During the button being hold pressed, the program executes in a loop continuously and increment a variable (named i) between 1 and 6. In every loop, the current number of the variable is sent to the LEDs and this way the dice rolls. At the time when the button is released, the dice stops rolling and the last value of the variable is displayed until the next button – press. The rolling speed is depended on a delay command, used at the end of the loop.
The process is actually a pseudorandom number generator because during the time when the dice is rolled (the button is pressed) the value of the variable I changes very fast among the numbers between 1 and 6. The random process is actually generated by the random - time used to roll the dice.
Step 3: Code and Circuit Diagram of Led Explained
For beginners, this video is very helpful.
Step 4: Code and Circuit Diagram of Pushbutton Explained
For beginners, this video is very helpful.
Step 5: Code:
For credit, please follow my following accounts.
Thanks
For more interesting projects connect with me on:
Youtube: https://www.youtube.com/channel/UCTS10_CRYJhT-vb9...
Facebook page: https://www.facebook.com/techeor1/
Instagram: https://instagram.com/official_techeor?igshid=uc8l10avryni