Introduction: LED DICE

Step 1: Index

1. Introduction

2. Materials

3. Building the circuits for LED

4. Connection of all circuits

5. Circuit check

6. Programming

7. Checking

8. Decorations

Step 2: INTRODUCTION to the LED Dice

This machine is design to replace dices. Users can build this machine to ensure it is absolute fairness since people can cheat on dice by changing the centroid (balance) of the dice. This machine makes fairness in games requiring dices such as Craps (game that rolls a set of dice while gamblers bet on the number before the roll). The machine is designed with an implanted dice. The user presses a button to roll the electronic dice. The result will be the number of lighted LED.

Step 3: Materials:

Card board *

Leonardo*1 with connector to PC

LED in red for 6

button*1

Circuit lines/ Arduino Connection lines

Glue/Hot glue

Breadboard if you need

Paint or color pencils if you want to draw and decorate it

Cutting tools

Step 4: Building the Circuits for LED

As the picture shown above all negative sides of LED are link to the same row that is for the GND side. All the positive rod of LED are linked to a inductance. The inductance are link to the digital pins after. The negative rods are all linked to GND to form a circuit.

Step 5: Circuits

Link a Button to D pin 12 and GND on each side. Link the Negative rods of LED to GND to. For the positive side of the LEDs, link then from D-pin2 - D-pin 6 separately.(you can change the places if you like but be sure to change the program.) Make sure there is no mistake again. The circuit can both work on Arduino Leonardo and Uno, just make sure there is no mistake make in the circuits.

Step 6: Programming

https://create.arduino.cc/editor/terry_outsider/f5...

The above is the link to program in Arduino.

The code:

int _dice ; // sets the dice

void setup() // put your setup code here, to run once:

{ pinMode( 2, OUTPUT); // set the D pin for LED1 // you can change the if you like

pinMode( 3, OUTPUT); // set the D pin for LED2 // you can change the if you like

pinMode( 4, OUTPUT); // set the D pin for LED3 // you can change the if you like

pinMode( 5, OUTPUT); // set the D pin for LED4 // you can change the if you like

pinMode( 6, OUTPUT); // set the D pin for LED5 // you can change the if you like

pinMode( 7, OUTPUT); // set the D pin for LED6 // you can change the if you like

pinMode( 12, INPUT); // sets the D pin for the Button // you can change the if you like

_dice = 0 ; //make sure no lights are on at the moment

digitalWrite( 2, LOW ); // sets the LED to close for the start

digitalWrite( 3, LOW ); // sets the LED to close for the start

digitalWrite( 4, LOW ); // sets the LED to close for the start

digitalWrite( 5, LOW ); // sets the LED to close for the start

digitalWrite( 6, LOW ); // sets the LED to close for the start

digitalWrite( 7, LOW ); // sets the LED to close for the start

}

void loop() // put your main code here, to run repeatedly:

{ if (digitalRead( 12 )) // if the button is pressed

{ _dice = random( 1, 6 ) ; // rolls the dice randomly, from 1-6

if ( _dice == 0 ) // if result is 0

{ digitalWrite( 2, LOW ); // sets the LED to close for the start

digitalWrite( 3, LOW ); // sets the LED to close for the start

digitalWrite( 4, LOW ); // sets the LED to close for the start

digitalWrite( 5, LOW ); // sets the LED to close for the start

digitalWrite( 6, LOW ); // sets the LED to close for the start

digitalWrite( 7, LOW ); // sets the LED to close for the start

}

if ( _dice == 1 ) // if result is 1

{ digitalWrite( 2, HIGH ); // turns on the LED// total:1

delay( 3000 ); //maintain the result to let people see it

digitalWrite( 2, LOW ); // closes the LED is closed after the results are shown

}

if ( _dice == 2 ) // if result is 2

{ digitalWrite( 2, HIGH ); // turns on the LED

digitalWrite( 3, HIGH ); // turns on the LED// total:2

delay( 3000 ); //maintain the result to let people see it

digitalWrite( 2, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 3, LOW ); // closes the LED is closed after the results are shown

}

if ( _dice == 3 ) // if result is 3

{ digitalWrite( 2, HIGH ); // turns on the LED

digitalWrite( 3, HIGH ); // turns on the LED

digitalWrite( 4, HIGH ); // turns on the LED// total:3

delay( 3000 ); // maintain the result to let people see it

digitalWrite( 2, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 3, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 4, LOW ); // closes the LED is closed after the results are shown

}

if ( _dice == 4 ) // if result is 4

{ digitalWrite( 2, HIGH ); // turns on the LED

digitalWrite( 3, HIGH ); // turns on the LED

digitalWrite( 4, HIGH ); // turns on the LED

digitalWrite( 5, HIGH ); // turns on the LED//total:4

delay( 3000 ); // maintain the result to let people see it

digitalWrite( 2, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 3, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 4, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 5, LOW ); // closes the LED is closed after the results are shown

}

if ( _dice == 5 ) // if result is 5

{ digitalWrite( 2, HIGH ); // turns on the LED

digitalWrite( 3, HIGH ); // turns on the LED

digitalWrite( 4, HIGH ); // turns on the LED

digitalWrite( 5, HIGH ); // turns on the LED

digitalWrite( 6, HIGH ); // turns on the LED// total:5

delay( 3000 ); // maintain the result to let people see it

digitalWrite( 2, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 3, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 4, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 5, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 6, LOW ); // closes the LED is closed after the results are shown

}

if ( _dice == 6 ) // if result is 6

{ digitalWrite( 2, HIGH ); // turns on the LED

digitalWrite( 3, HIGH ); // turns on the LED

digitalWrite( 4, HIGH ); // turns on the LED

digitalWrite( 5, HIGH ); // turns on the LED

digitalWrite( 6, HIGH ); // turns on the LED

digitalWrite( 7, HIGH ); // turns on the LED// total:6

delay( 3000 ); // maintain the result to let people see it

digitalWrite( 2, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 3, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 4, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 5, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 6, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 7, LOW ); // closes the LED is closed after the results are shown

} }

digitalWrite( 2, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 3, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 4, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 5, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 6, LOW ); // closes the LED is closed after the results are shown

digitalWrite( 7, LOW ); // closes the LED is closed after the results are shown

delay( 500 ); // stop LED from changing again and again

_dice = 0; // stop LED from changing again and again

}

Step 7: Checking

upload the program up your device and execute it for few times. Ensure there is no problem in the circuits and the device then you can proceed on the decoration of the dice.

Step 8: Decorations

Prepare cutting tools, card board, hot glue/ glue

Cut the cardboard into the below sizes (in cm) using the cutting tools

1. 19*13 2 pieces

2. 19*4.5 2 pieces

3. 13*4.5 2 pieces

Place Arduino on biggest side

Cut holes on 1 (19*4.5) side for implanting of LED and the button.

Organize the circuits and ensure the lines are correct

Cut an 2*3 hole at the bottom left of a (13*4.5) side for the main Arduino line to get to the PC

Look at the photos above arrange stick the boards like a cube in positions E, A, f, B and C in the front, D at the back.

A: the board under the Arduino board (19*13)

B: the board above the Arduino board (19*13)

C:The board that has implanted LED and Button (19*4.5)

D: The board that doesn't have implanted LED and Button (19*4.5)

E: The board that has a hole to let main wire out (13*4.5)

F: The board that doesn't have a hole to let main wire out (13*4.5)

Stick the 13cm side of E on one of A's 13 cm side.

Stick F's 13cm side on A's other 13 cm side which is the oppiste side of the side where E is sticking on.

Stick B on the top of E and F, stick both the 13 cm of B on the left out 13 cm side of E and F. Each 13 cm side of B matches on E's 13 cm side or F's 13 cm side. (Just like A)

Stick the D board on the side where the bread board is further. (The further hole in the 2 left holes)

Stick the remaining board on the remaining hole, and check the machine.

Draw something on it or just leave it like it

Step 9: Finished