Arduino Led Dice
This explaines how to create it in the breadboard, how to solder it and how to make some changes.
What Is Arduino?
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:
Parts & Tools
Parts:
- Arduino
- 7x Leds of any kind (I use 5mm Red Leds)
- A 10k Resistor (brown black orange)
- 7x 220 or 330 Resistor (red red brown or orange orange brown)
- A little Push Button
- Breadboard
- Some wires for the breadboard
- The arduino programmer (you can download it from the official site of Arduino)
- Usb Cable A-B
- Soldering Iron (If you want solder the project)
- A ProtoBoard (f you want solder the project)
- Solder Spool (If you want solder the project)
- Third Hand (optional, but useful if you want solder the project)
Schematic & Intro
To create all the faces of the dice, you must follow these rules:
For the number 2 of the dice: lights up the group 1
For the number 3 of the dice: lights up the groups 3 and 4
For the number 4 of the dice: lights up the groups 1 and 3
For the number 5 of the dice: lights up the groups 1, 3 and 4
For the number 6 of the dice: lights up the groups 1, 2 and 3
Place the Components on the Breadboard
After that, connect all the cathodes of the Leds to ground with 220 or 330 ohm resistors (red red brown or orange orange brown)
Then, put the pushbutton on the breadboard and connect it to ground with 10k ohm resistance.
Connect the Components With Arduino
First, attach the Arduino ground with the ground line of the breadboard
Then, connect the Leds to Arduino...this part can be a bit difficult, but there is an useful schematic.
Finally, connect the 5v of arduino with the button, and connect the button with the pin 6 of Arduino...be careful also in this part and follow the picture.
Hey...you're done!
Program Code
int pinLeds1 = 10;
int pinLeds2 = 9;
int pinLeds3 = 7;
int pinLed4 = 8;
int buttonPin = 6;
int buttonState;
long ran;
int time = 2000;
void setup ()
{
pinMode (pinLeds1, OUTPUT);
pinMode (pinLeds2, OUTPUT);
pinMode (pinLeds3, OUTPUT);
pinMode (pinLed4, OUTPUT);
pinMode (buttonPin, INPUT);
randomSeed(analogRead(0));
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH){
ran = random(1, 7);
if (ran == 1){
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (ran == 2){
digitalWrite (pinLeds1, HIGH);
delay (time);
}
if (ran == 3){
digitalWrite (pinLeds3, HIGH);
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (ran == 4){
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds3, HIGH);
delay (time);
}
if (ran == 5){
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds3, HIGH);
digitalWrite (pinLed4, HIGH);
delay (time);
}
if (ran == 6){
digitalWrite (pinLeds1, HIGH);
digitalWrite (pinLeds2, HIGH);
digitalWrite (pinLeds3, HIGH);
delay (time);
}
}
digitalWrite (pinLeds1, LOW);
digitalWrite (pinLeds2, LOW);
digitalWrite (pinLeds3, LOW);
digitalWrite (pinLed4, LOW);
}
Downloads
Test It!
This project is very useful for those who wants to begin to become familiar with Arduino, the code is easy, clean and funny.
Now, if you want to improve the project, you can try to solder it or make some changes, as explained in the next steps of instructable.
Solder the Arduino Led Dice
Solder is not easy, and if you are a beginner, I recommend to follow some guides on the web to learn it.
In the images, there's my old solder version of my Arduino led dice, and unfortunately, in this version each led is connected to an Arduino pin: during soldering, it's advisable to connect the LEDs in pairs as in the breadboard version, for convenience.
Project Variations
If you want to do this, simply connect the tilt switch to the 5V Arduino and the other side to pin 6 of Arduino, as in figure.
in this:
if (buttonState == LOW) {