Let's Roll a Dice
https://www.instructables.com/Arduino-Led-Dice/
This is a simple project of Arduino called let's roll a dice. This will show you how to create dice using Arduino. The function of these dice is when you are playing a board game you can replace the small dice with this. Playing with the small dice are annoying. Some time the regular dice might be disappearing, because it is too small. As a result, using the arduino dice is more useful and convenient.
Supplies
- Arduino
- 7x LEDs of any kind (I use Red LEDs)
- A 10k Resistor (brown black orange)
- 7x 220 or 330 Resistor (red-brown or orange-brown)
- A little Push Button
- Breadboard
- Some wires for the breadboard
CONNECT THE CIRCUITS
https://create.arduino.cc/editor/kittylin24/93841c... int pinLeds1 = 10;//改 int pinLeds2 = 8;//改 int pinLeds3 = 9;//改 int pinLed4 = 7;//改 int buttonPin = 6; int buttonState; long ran; int time = 2000; void setup () { pinMode (pinLeds1, OUTPUT); pinMode (pinLeds2, OUTPUT); pinMode (pinLeds3, OUTPUT); pinMode (pinLed4, OUTPUT); pinMode (buttonPin, INPUT); randomSeed(analogRead(0)); } void loop() { buttonState = digitalRead(buttonPin); if (buttonState == HIGH){ for (int i = 0; i < 3; i ++){ //改 digitalWrite (pinLed4, LOW);//改 digitalWrite (pinLeds1, HIGH);//改 delay (100);//改 digitalWrite (pinLeds1, LOW);//改 digitalWrite (pinLeds2, HIGH);//改 delay (100);//改 digitalWrite (pinLeds2, LOW);//改 digitalWrite (pinLeds3, HIGH);//改 delay (100);//改 digitalWrite (pinLeds3, LOW);//改 digitalWrite (pinLed4, HIGH);//改 delay (100);//改 } digitalWrite (pinLed4, LOW);//改 ran = random(1, 7); if (ran == 1){ digitalWrite (pinLed4, HIGH);//改 delay (time); } if (ran == 2){ digitalWrite (pinLeds1, HIGH); delay (time); } if (ran == 3){ digitalWrite (pinLeds3, HIGH);//改 digitalWrite (pinLed4, HIGH);//改 delay (time); } if (ran == 4){ digitalWrite (pinLeds1, HIGH);//改 digitalWrite (pinLeds2, HIGH);//改 delay (time); } if (ran == 5){ digitalWrite (pinLeds1, HIGH); digitalWrite (pinLeds2, HIGH);//改 digitalWrite (pinLed4, HIGH); delay (time); } if (ran == 6){ digitalWrite (pinLeds1, HIGH); digitalWrite (pinLeds2, HIGH); digitalWrite (pinLeds3, HIGH); delay (time); } } digitalWrite (pinLeds1, LOW); digitalWrite (pinLeds2, LOW); digitalWrite (pinLeds3, LOW); digitalWrite (pinLed4, LOW); }
Connect the Components!
1. Attach the Arduino ground with the ground line of the breadboard
2. Connect the LEDs to Arduino
3. Connect the 5v of Arduino with the button, and connect the button with pin 6 of Arduino
Test It!!!!
Now the Arduino is finished, you can test it. You can press the button and see it works. This project is very useful for someone who likes to play board games, it is very convenient and special.