Introduction: Arduino: Electronic Dice (using Random Numbers)

This instructable will show you how to make an electronic dice with minimal experience using 7 LEDs, resistors, jumper wires, and of course the arduino (or arduino clone). I wrote this instructable for anyone to easily follow along and learn more about the arduino. Questions are welcome and will be answered as soon as possible. For less experienced users the code for the arduino is in "longhand" and several comments are included for better understanding of the code being uploaded into the arduino.

Step 1: Parts List

Arduino or a clone ( I'm using a protoshield but a breadboard will work the same way)
11 Jumper Wires (or stripped wires in order to make connections on a breadboard)
7 Resistors (I used 330ohms) (ORANGE)(ORANGE)(BROWN)(GOLD)
7 LEDs ( I used green)
1 tactile switch or motions sensor (I used a motion sensor)

Step 2: Jumper Setup

In this step you will need to plug in 7 of the 11 wires. Jumper will be placed in digital plugs 2, 4, 5, 6, 7, 8, and 10; the other sides will be placed in the breadboard as shown below.

Step 3: Add Resistors

Now we will connect the resistors to the same column on the breadboard as the jumper wires. But the resistor will need to connect top gap to the bottom gap of the breadboard (check the picture it's really simple).

Step 4: Light It Up

Time to light up the breadboard with some Leds. There are 7 leds in all but their leads (+/-) need to be put into different ports in the breadboard. The way to do this on a breadboard is to have 3 Leds with their positive leads going into holes that are side by side, 1 led that needs to have the "positive" leads long enough to skip one hole in the breadboard, and 3 that skip 2 holes in between leads. Check the pictures, it's not nearly as hard as it seems.

After bending the Leds to the correct sizes place the Leds on the breadboard as it is shown below. NOTICE: the cathode(-) ends are going into columns without resistors and the anodes (+) are going into columns with resistors

Step 5: Add a Switch

Now it's time to add a switch. It's important that the switch is a momentary switch (when you push it the curcuit is closed and when you release the curcuit is open or vice versa). I use a motion sensor but the tactile switch will work in the same way.

For the tactile switch your going to need to connect it as it is below. NOTICE: two of the pins are on the same side that is the correct way to use a tact switch.

For the motion sensor I used I jumped it to the top and use a piece of wire to connect it to the bottom.

No matter what switch you use you will need to connect it to the 3volt port with a 270ohm resistor (red)(purple)(brown)(gold)

First Picture: shows the installation of the motion sensor and a jumper cable

Second Picture: shows the installation of a green jumper wire from the motion sensor to Digital Pin 12

Third Picture: shows the installation of a resistor from the 3v port to the same side of the motion sensor that the green jumper wire is connected to

Fourth Picture: shows the installation of a white jumper wire to the other side of the motion sensor and to ground

Fifth, Sixth, and Seventh Pictures: show the installation of a ground wire to the cathode column of the Leds

Eight Picture: shows how to use a tactile switch if you don't want to use or don't have a motion sensor

Step 6: Time for the Code

I put many comments in the .pde file that is going to be uploaded to the arduino so I'm not going to explain anything here. If you have questions write it in a comment or pm me and I will make sure to answer as best as I can. If there are any problems with the code please tell me but I have checked it many times and it seems to be working fine. And yes I know that the code is extremely inefficient when it comes to space but it was written this way for less experienced users.