Dice 2.0

by Phoebeyang in Circuits > Arduino

124 Views, 0 Favorites, 0 Comments

Dice 2.0

IMG_8107.JPG

Reference: https://www.instructables.com/Arduino-Led-Dice/

The task for this project is to find a reference Arduino project on "instructables.com" and try to modify by either adding a technical ability, or changing the coding.

In this project I will follow all steps the reference made, at the same time use the coding from the reference. Then I will be changing the delay time for the LED light of the dice light.

Supplies

  • Arduino UNO R3 control pane
  • Breadboard
  • LED lightbulb x6
  • Arcade push button
  • Jumper wires
  • 10k Resistor

Step 1: Prepare Your Materials

arduino-uno-r3-development-board.png
download.jpeg
download (2).jpeg
download (3).jpeg
R30220S-2.jpeg

Prepare all the materials or supplies listed above.

Step 2: Assemble Components & Connect Jumpers

IMG_8098.JPG
IMG_8099.JPG
IMG_8100.JPG
IMG_8101.JPG

1. Connect the positive to 5V and the negative to GND.

2. Place the LED light bulb in the a dice shape. Remember to leave enough spaces for wires to pass.

3. Place the 10k resistor on the same line to the right leg of the LED light bulb.

4. Connect the lines of the of D-pin and the light bulbs

5. Connect the lines from the 10k resistor to the negative.

6. Connect the lines for the button.

Step 3: Upload Code & Make Changes

Screen Shot 2021-04-13 at 3.27.24 AM.png
Screen Shot 2021-04-13 at 3.28.01 AM.png
Screen Shot 2021-04-13 at 3.28.31 AM.png

Link to the coding: https://create.arduino.cc/editor/phoebeyang/82c3e2...

//Arduino code by Davuzz11
//Led dice With Arduino //Changed by Phoebeyang

//Led pins int pinLeds1 = 10;

int pinLeds2 = 9;

int pinLeds3 = 7;

int pinLed4 = 8;

//Button pin

int buttonPin = 6;

int buttonState;

//Ran will be randomized from 1 to 6 long ran;

//Time is the time of delay int time = 1000; //changed the time from 2000 to 1000

void setup ()

{ //Set the pins of the leds as Output

pinMode (pinLeds1, OUTPUT);

pinMode (pinLeds2, OUTPUT);

pinMode (pinLeds3, OUTPUT);

pinMode (pinLed4, OUTPUT);

//Set the pin of the button as an Input

pinMode (buttonPin, INPUT);

//This code line is necessary for a correct random

randomSeed(analogRead(0));

}

void loop()

{

//Read the status of the button

buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {

//Randomize from 1 to 6

ran = random(7);

//Number 1!

if (ran == 1) {

digitalWrite (pinLed4, HIGH);

delay (time);

}

//Number 2!!

if (ran == 2) {

digitalWrite (pinLeds1, HIGH);

delay (time);

}

//Number 3!!!

if (ran == 3) {

digitalWrite (pinLeds3, HIGH);

digitalWrite (pinLed4, HIGH);

delay (time);

}

//Number 4!!!!

if (ran == 4) {

digitalWrite (pinLeds1, HIGH);

digitalWrite (pinLeds3, HIGH);

delay (time);

}

//Number 5!!!!!

if (ran == 5) {

digitalWrite (pinLeds1, HIGH);

digitalWrite (pinLeds3, HIGH);

digitalWrite (pinLed4, HIGH);

delay (time);

}

//Number 6!!!!!!

if (ran == 6) {

digitalWrite (pinLeds1, HIGH);

digitalWrite (pinLeds2, HIGH);

digitalWrite (pinLeds3, HIGH);

delay (time);

}

}

//If the button is not pressed, sets off the leds

digitalWrite (pinLeds1, LOW);

digitalWrite (pinLeds2, LOW);

digitalWrite (pinLeds3, LOW);

digitalWrite (pinLed4, LOW);

}

//....Finish!

Step 4: Testing Dice 2.0

Arduino_ Dice 2.0
IMG_8103.JPG
IMG_8104.JPG

Step 5: Creating Cover (optional)

IMG_8105.JPG

Create a cover made by either;

- paper

- cardboard

- box

- container

to cover up all the messy wires.

For me, its just a plain white paper. Simple.