loading
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.



Please comment if you have questions or suggestions on how to make this instructable better... thanx
You forgot to set the pinMode to OUTPUT for middleLeft and middleRight.<br><br>Great instructable! I love how neat your wiring is. I made LED dice before reading this instructable, but mine looks like a mess.
Hi, i made a arduino dice following https://www.instructables.com/id/Digital-Dice-an-Arduino-project/ - would you know how to make the lights flash randomly before settling on a number (i.e to simulate the 'rolling' of a die)? Cheers
I would just like to emphasize that the code I wrote is not optimized to work efficiently but written for beginners to begin to see how it works. I have updated the code to flash randomly 6 times before picking the final number. Let me know if there are any problems as I have not actually tested it. :)<br><br>http://www.mediafire.com/?bidb4kb3usxe7f3
Nice. An electronic die is exactly what I did as my first from scratch arduino project. :)<br><br>On the random front, as stated, seeding from an analog port seems to work well.<br><br>Also, in the interest of reducing the code, and a possible further exercise for anyone doing this instructable, you can reduce the number of i/o pins down to 4 for a standard d6.<br><br>Nice instructable. You beat me to doing the same one! :)
Heh, just realised how old this instructable was! It has just been posted on electronics-lab.com blog! :)
How do you overcome the fact the the random function in the arduino always uses the same sequence of random numbers, thus making it predictable?
Even if it used the same sequence (which i do not believe it does, i think it works based on the clock of the atmega328 but i haven't read up on it) it is so long that if you memorize the sequence you either have an incredible memory or you use it too much ;)<br />
Well I was trying to make a random number generator to simulate dice. I used the serial.print command to log the sequence random(1,6) and it was always the same! Someone suggested using randomSeed(analogRead(0)) so Ill have to give it a try...<br />
huh i didn't know that... tell me what you find... I thought the random was much like a computers random number that is based off of the clock (ms)...<br />
it looked like some of the risistors were backwards or does it matter?<br />
for resistors it doesn't matter which way they are...<br />in other words resistors are not effected by polarity.. :)<br />

About This Instructable

20,996views

15favorites

License:

More by redryno1221:Corsair Link Fan Controller Mod Microview CPU Monitor Arduino: Electronic Dice (using random numbers) 
Add instructable to: