Electronic Dice Using Arduino

by Mudit5246 in Circuits > Arduino

1814 Views, 4 Favorites, 0 Comments

Electronic Dice Using Arduino

3lXtOE1Qq59j160iBoAK.jpg

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.

Component Required:

51rmayrbsPL._AC_SX466_.jpg
1.png47FDAC7E-0763-47BD-A99B-50375903586BDefaultHQ.jpg
download (1).png
download (2).jpg
download (3).jpg
download (4).jpg
  1. Arduino UNO
  2. LED's*7
  3. Pushbuttons *2
  4. Connecting wires
  5. Breadboard
  6. 1 k & 220 ohms resistor
  7. Power supply
  8. Buzzer

Circuit Diagram:

digital dice (1).png

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.

Code and Circuit Diagram of Led Explained

Basic concepts of Arduino step by step | Part-1 | Code fully explained

For beginners, this video is very helpful.

Code and Circuit Diagram of Pushbutton Explained

Basic concepts of Arduino step by step | Part-2 | Code fully explained

For beginners, this video is very helpful.

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