Digital Dice Using Arduino (Step by Step)
by Yusuf Jasny in Circuits > Arduino
543 Views, 2 Favorites, 0 Comments
Digital Dice Using Arduino (Step by Step)
This instructable will show how to create a Smart & Digital Dice Using Arduino and few components.
Are you playing Snake and Ladder or Ludo? If you are, I am almost sure that you use normal dice. Well, that is until today.
After creating this project, I am pretty sure that the next time you play ludo you will use the digital dice that I present in this post.
How Does It Work? It works is very simple. There is a button, if you press the button it will randomly select a number and show it on 7-segment display.
Let's start !
It's an easy and fun project, suitable for beginners and kid-friendly.
And this instructables is very clear and easy to understand.
Supplies
It requires a minimal amount of components and low cost material which can be find easily.
Things You Need
1. Arduino Uno x 1
2. Seven segment display x1
3. Push buttons x 1
4. Jumper Wires
5. Bread board x 1
6. Resistor x 1
I will be Using Arduino Uno in this instructables, but you can use other similar board like Arduino mega.
It requires a minimal amount of components and low cost material which can be find easily.
Wiring Up (Diagram)
I have tested this project and it works well.
So I hope you connect the wires correctly as the above diagram.
Uploading the Code
1. Open the Arduino IDE in your computer.
2. Copy the code given below and paste in the arduino IDE.
3. Then connect your arduino board.
4. Upload the sketch.
#include "SevSeg.h"SevSeg sevseg; long randNumber;const int buttonPin = 10;int buttonState = 0; void setup(){ Serial.begin(9600); byte numDigits = 1; byte digitPins[] = {}; byte segmentPins[] = {6, 5, 2, 3, 4, 7, 8, 9}; bool resistorsOnSegments = true; randomSeed(analogRead(0)); byte hardwareConfig = COMMON_CATHODE; sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments); sevseg.setBrightness(100); pinMode(buttonPin, INPUT);}void loop(){ int i; randNumber = random(1, 7); Serial.println(randNumber); i = randNumber; sevseg.setNumber(i, i%2); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { delay(3000); } else { delay(30); } sevseg.refreshDisplay(); }
5. Make sure you connect the wires correctly.
I hope it works fine, It works perfectly for me.
Now you can use your digital dice when you play ludo.
If you have any errors or questions comment below ?
Thank you