You are on page 1of 11

Food Living Outside Play Technology Workshop

LED Die with Arduino


by braulio777 on April 25, 2013

Table of Contents

LED Die with Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: LED Die with Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Bill of Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Step 2: Install the LEDs and Resistors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 3: Diagram of Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 4: Continue with the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 5: Connect the Mini Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Step 6: Connect your Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Step 7: Program of the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

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

Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

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

http://www.instructables.com/id/LED-Die-with-Arduino/
Intro: LED Die with Arduino
This project is a die that you will do with 7 LEDs, 8 resistors and a small switch. Once you construct the die, you will connect it to an Arduino hardware to download the
program and you can utilize the die by manipulating a small switch.

http://www.instructables.com/id/LED-Die-with-Arduino/
Step 1: Bill of Materials
1 Breadboard
7 LEDs
7 resistors of 200?
1 resistor of 1K?
1 Mini switch

http://www.instructables.com/id/LED-Die-with-Arduino/
Step 2: Install the LEDs and Resistors
Install the LEDs and resistors of 200? on the protoboard by observing the polarities of the LEDs. Remember that short terminal in a LED is the negative terminal that you
will have to connect to the resistors of 200? by leaving free the other terminals to connect to your Arduino: Li to D7, L2 to D8, L3 to D9, L4 to D10, L5 to D11, L6 to D12
and L7 to D13. And the other terminals of the resistors connect to GND (blue line).

http://www.instructables.com/id/LED-Die-with-Arduino/
Step 3: Diagram of Project

http://www.instructables.com/id/LED-Die-with-Arduino/
Step 4: Continue with the Project
Connect the rest of the components on the protoboard. That is, the preparation of the connections will use to connect to your Arduino later.

Step 5: Connect the Mini Switch


Connect the mini switch and do the necessary connections on your protoboard to wait only by your Arduino.

http://www.instructables.com/id/LED-Die-with-Arduino/
http://www.instructables.com/id/LED-Die-with-Arduino/
Step 6: Connect your Arduino
In this step,you will oonnect the arduino hardware to the protoboard and will install the program for this project that you will see in the following step the detailed program
for managing the project.

http://www.instructables.com/id/LED-Die-with-Arduino/
http://www.instructables.com/id/LED-Die-with-Arduino/
Step 7: Program of the Project
With the following program, you will have concluded your project once you download it by utilizing Arduino environment and click on load; you will have running the
program to utilize your project.

Program for the LED Die Circuit


//Arduino Code

/*LED DIE*/
//Select your led pins
int ledPins[7] = {7, 8, 9, 10, 11, 12, 13};
int dicePatterns[7][7] = {
{0, 0, 0, 0, 0, 0, 1}, // 1
{0, 0, 1, 1, 0, 0, 0}, // 2
{0, 0, 1, 1, 0, 0, 1}, // 3
{1, 0, 1, 1, 0, 1, 0}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 1, 1, 1, 1, 1, 0}, // 6
{0, 0, 0, 0, 0, 0, 0} // BLANK
};
int switchPin = 5;
int blank = 6;
void setup()
{
for (int i = 0; i < 7; i++)
{
pinMode(ledPins[i], OUTPUT);
digitalWrite(ledPins[i], LOW);
}
randomSeed(analogRead(0));
}
void loop()
{
if (digitalRead(switchPin))
{
rollTheDice();
}
delay(100);
}
void rollTheDice()
{
int result = 0;
int lengthOfRoll = random(15, 25);
for (int i = 0; i < lengthOfRoll; i++)
{
result = random(0, 6); // result will be 0 to 5 not 1 to 6
show(result);
delay(50 + i * 10);
}
for (int j = 0; j < 3; j++)
{
show(blank);
delay(500);
show(result);
delay(500);
}
}
void show(int result)
{
for (int i = 0; i < 7; i++)
{
digitalWrite(ledPins[i], dicePatterns[result][i]);
}
}

http://www.instructables.com/id/LED-Die-with-Arduino/
Related Instructables

Arduino How to use


Turn Your
Examples #2 Wireless upload Arduino Mega How to program Arduino Into an
2560 as Arduino ATtiny
Use an Arduino program to programming attiny using
as a FTDI ISP by mr_mac3
Arduino without isp by tsillen arduino uno by
with Arduino by
Programmer by USB cable by Pranavthegreat
wirenut1980
qazwsx755 ITEAD STUDIO

Advertisements

Comments
3 comments Add Comment

nox1468 says: Apr 30, 2013. 6:42 AM REPLY


nice work, but i was wondering, could i make the arduino's outputs each lead to six LEDs so i could make a six-sided die that shows the resulting number on
all six sides?

braulio777 says: Apr 30, 2013. 8:54 AM REPLY


Congratulation nox1468, I will be submitting more arduino projects later.

braulio777 says: Apr 27, 2013. 11:29 PM REPLY


This project is to all people who want to begin to work with Arduino's programs and they want to do their second project. Enjoy it!!

http://www.instructables.com/id/LED-Die-with-Arduino/

You might also like