0% found this document useful (0 votes)
59 views13 pages

Arduino Led Dice

Dados led con arduino

Uploaded by

wilmaraf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
59 views13 pages

Arduino Led Dice

Dados led con arduino

Uploaded by

wilmaraf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 13

Home Sign Up!

Browse Community Submit


All Art Craft Food Games Green Home Kids Life Music Offbeat Outdoors Pets Photo Ride Science Tech

Arduino Led Dice


by Davuzz11 on October 30, 2009

Table of Contents

Arduino Led Dice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Arduino Led Dice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: What is Arduino? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Why Arduino? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

How do I use Arduino? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 2: Parts & Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 3: Schematic & Intro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 4: Place the components on the breadboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 5: Connect the components with Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 6: Program Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 7: Test it! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Step 8: Solder the Arduino led dice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 9: Project variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

http://www.instructables.com/id/Arduino-Led-Dice/
Intro: 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.

Image Notes
1. Arduino Led Dice in action!

Step 1: 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:

Windows
Mac OS X
Linux
(All this part was taken from the official website of Arduino)

http://www.instructables.com/id/Arduino-Led-Dice/
Image Notes
1. This is an old version of Arduino

Image Notes
1. This is Arduino!

Step 2: Parts & Tools


This is what you need for this simple project:

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

Tools:

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)

Image Notes
1. BreadBoard
2. Arduino!
http://www.instructables.com/id/Arduino-Led-Dice/
3. 7x 220 Ohm Resistor
4. 1x 10k Ohm Resistor
5. 7x Red 5mm Leds
6. A PushButton

Step 3: Schematic & Intro


To create all the six faces of a dice, you need 7 LEDs, placed in the shape of an "H".
As you can see from the diagram, they're not all linked to different pins of Arduino, but most are connected in pairs, to facilitate the use.
To create all the faces of the dice, you must follow these rules:
For the number 1 of the dice: lights up the led 4
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

If you want to see the schematic with more detail, click here:
http://www.instructables.com/files/orig/F5L/A4E0/G1BB7YY2/F5LA4E0G1BB7YY2.jpg

Image Notes
1. Arduino board
2. Ground
3. Pushbutton

Step 4: Place the components on the breadboard


First, place the Leds in the shape of an "H". It may be a little difficult to find the right configuration without superimpose the leds, but in the pictures there is a scheme to
facilitate this part.
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.

Image Notes
Image Notes 1. Led 1
1. 1) Place the Leds 2. Led 1
3. Led 2
4. Led 2
5. Led 3
6. Led 3
7. Led 4
8. <--- I placed the LED in this way

http://www.instructables.com/id/Arduino-Led-Dice/
Image Notes Image Notes
1. 2) Connect all the Leds to the Ground line with 220 or 330 Ohm Resistors 1. 3) Place the Push button and connect it to the Ground line with a 10k Ohm
Resistor
2. 10k Ohm

Step 5: Connect the components with Arduino


Now....let's take 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!

Image Notes Image Notes


1. Let's take arduino! 1. 5) Connect the leds to the Arduino pins...To understand this step, you can
2. 4) Connect the Arduino Ground with the Ground line of the breadboard read the schematic in the next picture

http://www.instructables.com/id/Arduino-Led-Dice/
Image Notes
1. 6) Connect the 5v of the Arduino to this Button pin
2. 6) Connect this pin of the Pushbutton with Arduino
Image Notes
1. PushButton
2. 10k Ohm Resistor
3. This is how the Leds are connected to the Arduino pins...*REMEMBER to
connect every Led to the ground with a 220 or 330 Ohm Resistor*

Image Notes
http://www.instructables.com/id/Arduino-Led-Dice/
1. ...You have finish!

Step 6: Program Code


This is the code without the comments to reduce the space (You can find the comments in the downloadable file):

int pinLeds1 = 10;


int pinLeds2 = 9;
int pinLeds3 = 8;
int pinLed4 = 7;
int buttonPin = 6;
int buttonState;
int 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);
}

File Downloads

Dice.pde (1 KB)
[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Dice.pde']

http://www.instructables.com/id/Arduino-Led-Dice/
Step 7: Test it!
Now the Arduino led dice is finished and you can try it...you just have to power Arduino and press the button to see the number!
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.

Image Notes Image Notes


1. Showing number 1! 1. Showing number 2!!

Image Notes Image Notes


1. Showing number 3!!! 1. Showing number 4!!!!

http://www.instructables.com/id/Arduino-Led-Dice/
Image Notes Image Notes
1. Showing number 5!!!!! 1. Showing number 6!!!!!!

Step 8: Solder the Arduino led dice


If you want, you can also solder the project, to make it more compact and better.
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.

Image Notes Image Notes


1. Solder 1. This is my old version and unfortunately every led in connect with an Arduino
2. ProtoBoard pin...sorry!
3. Desoldering tool (optional) 2. Button Pin
4. Soldering Iron 3. Ground pin
5. Soldering Iron holder with sponge
6. Third Hand (optional)

Image Notes
1. My old version connected to arduino

http://www.instructables.com/id/Arduino-Led-Dice/
Step 9: Project variations
You can also apply funny changes to the project, such as using a tilt switch or a vibrator switch instead of the button. So, to read the number of the dice just shake the
breadboard, and it's funny!
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.

For the tilt switch, you need to change this line code:
if (buttonState == HIGH) {
in this:
if (buttonState == LOW) {
Now you just have to take the project in hand, shake it (without breaking it!) and read the number!

Image Notes Image Notes


1. The Tilt switch (oh...bad lighting, sorry!) 1. The tilt switch connected to arduino. Note that is not have any resistor

Image Notes Image Notes


1. Now connect with arduino and take it in your hand... 1. ....shake it...

http://www.instructables.com/id/Arduino-Led-Dice/
Image Notes
1. ...and read your number!

Related Instructables

Arduino: Digital Dice: an Arduino Fading LED with arduino control High-Low
Electronic Dice Arduino project. Tutorial: Flicker Arduino by leds with a pot Binary LED
(using random by dunnos a LED by Robot Lover meter by Arduino Game
numbers) by TXTCLA55 meauummels by A_Steingrube
redryno1221

Comments
20 comments Add Comment

kloptops says: Jan 28, 2011. 1:48 AM REPLY


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.

http://dl.dropbox.com/u/7992054/arduino/Dice.pde

mazmoiz says: Dec 7, 2010. 1:15 AM REPLY


Hi, can you plz tell me the name of the software in which you have created this schematic ? thanks alot, Maz

Davuzz11 says: Dec 7, 2010. 9:32 AM REPLY


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!

cdousley says: Jun 23, 2010. 2:41 PM REPLY


if i programmed an atmega with arduino then removed the atmega from the arduino board and hooked it up would it work or do i need to hook up a crystal to
it.

Davuzz11 says: Jun 24, 2010. 12:27 AM REPLY


Yes, if you detach the atMega (be careful) you can use it in a breadboard, but every time you need to program it, you have to reinsert the atMega on the
Arduino board. However, here is explained how to do it: http://www.instructables.com/id/Standalone-Arduino-ATMega-chip-on-breadboard/

cdousley says: Jun 26, 2010. 10:28 AM REPLY


ok thanks for your help.

http://www.instructables.com/id/Arduino-Led-Dice/
BenStep42 says: Feb 22, 2010. 12:13 PM REPLY
I'm new to the microcontroller game, but arduino seems to be the best fit for what I want to do as far as controlling led patterns and such.. Can the arduino
set up a continuous lighting sequence for led's and then be disconnected and run the same? I mean can I program a sequence for a project and have the
led's remember the code without the arduino still connected?

cdousley says: Apr 7, 2010. 10:55 AM REPLY


you cant do that but for your idea you could use an atmel atmega(the mictrocontroler on the arduino) the arduino is best for prototyping once you get it
made you can use the armega

NXTreme says: Mar 16, 2010. 11:17 AM REPLY


Another really great easy to program microcontroller is the PICAXE. If you just want to blink a couple LEDs a 08M would be perfect. While the Arduino is
probably more powerful ect. the PICAXE is really easy to program and they are super cheap. Just an idea.

Davuzz11 says: Mar 5, 2010. 9:31 AM REPLY


Sorry for the waiting!
However, you cannot run the sequence of led's disconnecting Arduino, simply because the sequence is done by the Arduino.
If your problem is keep attacking Arduino to your computer, you can connect a 9 volt battery and make Arduino "portable".
If you want to program the sequence without Arduino because it occupies too much space, you can use another microcontroller, like Picaxe or Atmel,
which are very small and they can be used in the breadboard.

darkesthour says: Mar 4, 2010. 8:02 PM REPLY


The Microcontroller itself has to still be on the board. But you can disconnect it from your computer and power say with a 9 volt battery or wall wart of
sorts.

cdousley says: Apr 5, 2010. 6:41 PM REPLY


This is great! this is my first arduino project and it worked perfectly the numbers were random and it rolled great.

electronics4you says: Mar 27, 2010. 3:30 AM REPLY


Hi Everyone,
I built this project today and came across an error in the code. According to the circuit diagram, the pin configuration should be this:
int pinLeds3 = 7;
int pinLed4 = 8;
It's written the other way around in the downloadable pde of this instructable.
Hope this was helpful..!

crzy engineer says: Feb 7, 2010. 6:10 PM REPLY

Perfect!

Paul Smith says: Jan 16, 2010. 6:07 PM REPLY


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?

http://www.instructables.com/id/Arduino-Led-Dice/
Davuzz11 says: Jan 17, 2010. 6:35 AM REPLY
You can overcome this fact simply putting in the Setup function this line code:
randomSeed(analogRead(0));

However, this line code is already present in the complete code of the instructables.

Axaj says: Dec 2, 2009. 3:01 PM REPLY


Dice is plural, die is singular.

Davuzz11 says: Nov 16, 2009. 5:45 AM REPLY


Thanks to all!

oscarthompson says: Nov 14, 2009. 1:26 PM REPLY


brilliant!... Im just beging the kind of stuff (thanks to Maplins™, the electronics specialist!)

LuminousObject says: Nov 14, 2009. 1:17 PM REPLY


Awesome. I like the shaking dice one.

http://www.instructables.com/id/Arduino-Led-Dice/

You might also like