Picture of Arduino Led Dice
This instructable will show you how to create a dice using Arduino and few components. It's an easy and fun project, suitable for beginners and those who want to start with Arduino; it also requires a minimal amount of components.
This explaines how to create it in the breadboard, how to solder it and how to make some changes.

Step 1: What is Arduino?

Picture of What is Arduino?
Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer. It's an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board.

Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects can be stand-alone, or they can be communicate with software running on your computer (e.g. Flash, Processing, MaxMSP.) The boards can be assembled by hand or purchased preassembled; the open-source IDE can be downloaded for free.

The Arduino programming language is an implementation of Wiring, a similar physical computing platform, which is based on the Processing multimedia programming environment.

Why Arduino?

There are many other microcontrollers and microcontroller platforms available for physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard, and many others offer similar functionality. All of these tools take the messy details of microcontroller programming and wrap it up in an easy-to-use package. Arduino also simplifies the process of working with microcontrollers, but it offers some advantage for teachers, students, and interested amateurs over other systems:

  • Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller platforms. The least expensive version of the Arduino module can be assembled by hand, and even the pre-assembled Arduino modules cost less than $50
  • Cross-platform - The Arduino software runs on Windows, Macintosh OSX, and Linux operating systems. Most microcontroller systems are limited to Windows.
  • Simple, clear programming environment - The Arduino programming environment is easy-to-use for beginners, yet flexible enough for advanced users to take advantage of as well. For teachers, it's conveniently based on the Processing programming environment, so students learning to program in that environment will be familiar with the look and feel of Arduino
  • Open source and extensible software- The Arduino software and is published as open source tools, available for extension by experienced programmers. The language can be expanded through C++ libraries, and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. SImilarly, you can add AVR-C code directly into your Arduino programs if you want to.
  • Open source and extensible hardware - The Arduino is based on Atmel's ATMEGA8 and ATMEGA168 microcontrollers. The plans for the modules are published under a Creative Commons license, so experienced circuit designers can make their own version of the module, extending it and improving it. Even relatively inexperienced users can build the breadboard version of the module in order to understand how it works and save money.

How do I use Arduino?

Step-by-step instructions for setting up the Arduino software and connecting it to an Arduino Duemilanove:

(All this part was taken from the official website of Arduino)
1-40 of 50Next »
Tschec713 made it!3 days ago

Glad I found this, I was working on the same thing and was having a
hard time generating a random number. Now it works, Thank you

bul0019 made it!26 days ago

Thanks for the instructable

rolandosd made it!1 month ago

I Made it!!!! It did not ended as pretty as yours but at least it work hahahaha

nullf0x1 month ago


partho2223 months ago
inktomi4 months ago

finish this project with some boy scouts. basic starter kit, couple extra LEDs, 2 hours working with the boys. I liked some of the type o it allowed for troubleshooting. great starter project

raulcorde4 months ago

It works!! But i think there is an error in the code, at pin set:

int pinLeds3 = 7;
int pinLed4 = 8;

Should be:

int pinLeds3 = 8;
int pinLed4 = 7;

I'm going to try with a tilt switch as you suggested.


la foto.JPG
Emersonian5 months ago
DarrenXu 1 year ago
ruhliar made it!1 year ago

Thank you I made it.


i made it online works fine. u can simulate it here...http://123d.circuits.io/circuits/253088-dice/

Xenia_mix made it!1 year ago

it was fun! thanks for the instructable :)

Ploopy1 year ago

i just made one!
PapaBA1 year ago
I got involved with Arduino a month ago after years away from hands on coding & electronics. Building, troubleshooting, & expanding this project was a great contribution to my learning. Thanks.
PapaBA1 year ago
Some say 2 of the LED groups should be assigned as:
// Led pins ...
int pinLeds3 = 7;
int pinLeds4 = 8;
which is correct to the SCHEMATIC & the final code, BUT ...
the ILLUSTRATIONS differ on this so ...

Others (like me) said the opposite:
// Led pins ...
int pinLeds3 = 8;
int pinLeds4 = 7; (we followed the ILLUSTRATIONS & adjusted the code)

Either way should work IF ...
our version of LED assignments matches our circuit connections.
PapaBA1 year ago
Thanks for posting this.
kloptops post confirmed for me that the code needs to be
// Led pins ...
int pinLeds3 = 8;
int pinLeds4 = 7; (reversing the last 2 pins)

I enjoyed blending your approach with Binary_Dice_Game by Maik Schmidt
Code & illustrations by you & klopstops helped me see patterns to create a output_result() function using boolean logic instead of if:

void output_result() {

digitalWrite (pinLeds4, HIGH && (ran % 2 == 1)); // Odd Numbers light middle dot

digitalWrite (pinLeds3, HIGH && (ran >= 3)); // > 2 also light lower left & upper right

//Numbers even or 5 or 7 (winner) also light upper left & lower right
digitalWrite (pinLeds1, HIGH && ((ran % 2 == 0) || (ran == 5) || (ran == 7)));

digitalWrite (pinLeds2, HIGH && (ran >= 6)); // Number 6 or 7 (winner) also light mid left & right


// LEDs off (no button pressed OR clear display)
void Clear_LEDs () {
digitalWrite (pinLeds1, LOW);
digitalWrite (pinLeds2, LOW);
digitalWrite (pinLeds3, LOW);
digitalWrite (pinLeds4, LOW);
Instead of using 7 separate resistors for the leds, couldn't you just hook all their cathodes together, then hook them up to ground through a single resistor? If not, could you please briefly explain why it wouldn't work?
teknohawk2 years ago
Wow thanks! This is something I definetly want to build! :0 ;) :) Yay!
mr.future112 years ago
finally did this project it was nice starting with dice. but i want to blink led blindly before the no comes on after pressing the button. i tried it but it was not as good as i thought of.
Davide311 (author)  mr.future112 years ago
Well done! For making leds blink like a dice before you press the button, you can try the modified code posted by "kloptops" some time ago. This is the link: http://dl.dropbox.com/u/7992054/arduino/Dice.pde
It' not a really "random" sequence, but i think it will work the same.
If you use that code, remember to change the code in the first lines from:
int pinLeds3 = 8;
int pinLeds4 = 7;
int pinLeds3 = 7;
int pinLeds4 = 8;
mr.future112 years ago
made it finally. first project in arduino.. guys want help i want to blilnk leds randomly before the led show the no after pressing. i tried it but wasnt satisfied with it. so if anyone could help then please
Lendss3 years ago
I built one but it didn't worked well, so i looked
int pinLeds3 = 7;
int pinLed4 = 8;
and in this way my dice don't works well, but with
int pinLed4 = 7;
int pinLeds3 = 8;
it works perfectly.
Probably it's my fault but can you check it?
Thanks a lot
P.S. Awesome project
If you follow the schematic "correctly", this is the proper definition for the program. As my friend so cleverly noticed. Still an epic circut. Time to play RISK

//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 = 2000;
Davide311 (author)  _-MacGyver-_3 years ago
Whoops! Thank you for the correction, i just fixed it!
Very nice instructable it was easy to fallow along and do. I love it! Now I will try to make a shield for it, I will post photos of the shield when I get parts to make the shield.
Davide311 (author)  WakeUpWolfgang3 years ago
Great idea, and thank you for the interest! Ask if you need some help
I got the rest of the parts for it yesterday but we had to use my soldering room for some people to stay over but I should have it done some time this week I will post photos of it when its done.
Davide311 (author)  WakeUpWolfgang3 years ago
Ok, if you want i can add your photos in the instructable...and Merry Christmas!
Sorry for the noobish question, can someone explain to me whats the significance of :
ran = random(1, 7);

Much appreciated. By the way this is a fantastic project to learn with.
Davide311 (author)  FinalTrigger3 years ago
Sorry for the waiting!
" randomSeed(analogRead(0)); " is needed for have a correct randomness (without it, the arduino will use the same sequence every time).
" ran = random(1, 7); " set the variable "ran" equal to a number from 1 to 6, that is the result.
With my limited programming experience im guessing "randomSeed(analogRead(0));" is preparing the program to create a random number and "ran = random(1,7);" is setting ran (a variable?) equal to a random number valued 1 through 7
crob093 years ago
Very nice!! Just wondering if I can quote you and have some of this information on my website http://www.whatisacnc.com I found this very informative, thank you regardless of your decision.
Davide311 (author)  crob093 years ago
Sure you can quote my instructable! Thank you for the interest, and happy Christmas :D !
kloptops4 years ago
Nice design, however i decided to make the display routine a bit more interesting with it showing a "random" sequence before displaying the final result.

Thanks for the great starter project.

Great improvement! :)
Paul Smith5 years ago
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?
Davide311 (author)  Paul Smith5 years ago
You can overcome this fact simply putting in the Setup function this line code:

However, this line code is already present in the complete code of the instructables.
mazmoiz4 years ago
Hi, can you plz tell me the name of the software in which you have created this schematic ? thanks alot, Maz
Davide311 (author)  mazmoiz4 years ago
The software that i use is Fritzing, you can download it here: http://fritzing.org/download/ .
It also has the stardard layout of the arduino!
1-40 of 50Next »