7-Segment LED Die W/Arduino and More

by braulio777 in Circuits > Electronics

6263 Views, 13 Favorites, 0 Comments

7-Segment LED Die W/Arduino and More

7-Segment LED Die w/Arduino
Image06192013213305.jpg
Image06192013213055.jpg
Image06192013213107.jpg
Image06192013213218.jpg
Image06192013213233.jpg
Image06192013213317.jpg
This project is based on arduino environment so that you can manipulate a die with a simple 7-segment LED and mini switch of control.
Watch the video at: http://www.youtube.com/watch?v=-kSp8QqmcOc

Important note: I did an error because I wrote 2N3904 instead of 2N3906 for the transistor used in this project.

Bill of Materials

Image06142013185733.jpg
1 PROTOBOARD, 2.5"x4.25", 640 HOLES, PLATED THRU-HOLE
or  1 Photoshield kit for arduino
1 Connector Unshrouded Header 40 Position 2.54mm Solder Straight Thru-Hole
8 RESISTOR,CARBON FILM,200 OHM,1/4 WATT,5%
1 RESISTOR,CARBON FILM,1K OHM,1/4 WATT,5%
1 RESISTOR,CARBON FILM,10K OHM,1/4 WATT,5%
1 Switch Tactile ON OFF Single Pole
1 Transistor 2N3906
1 Common anode Seven-segment LED 

Project's Diagram

Observe your diagram so that you can correctly began and finish your project. 

Important note: it's not 2N3904 but 2N3906 the transistor used in this project.

Install the Pins

Image06142013191030.jpg
Image06142013193113.jpg
Image06142013193126.jpg
Image06142013195401.jpg
Image06142013195542.jpg
Image06142013195707.jpg
In this step, need to install the pins of connection to your arduino by inserting them in your arduino, first, and then you should mount the PCB by matching with the pins so that you can exactly solder where it should be.  Once you do that, you can dismount the PCB of your arduino so that you can see it with the pins up.

Install LED Display

Image06142013230632.jpg
Image06142013200324.jpg
Image06142013201416.jpg
Image06142013202653.jpg
Image06142013230605.jpg
Image06142013230617.jpg
In this step, install the LED display and its resistors of 200 ohm.

Install the Transistor, Switch and Resistors

Image06152013005639.jpg
Image06142013232102.jpg
Image06152013001620.jpg
Image06152013005718.jpg
Image06152013005729.jpg
Install the transistor, switch and the resistor of 1K and of 10K so that you can complete your project.

Upload Program and Probe Your Project

Image06192013213045.jpg
Image06192013213218.jpg
Image06192013213233.jpg
Image06192013213305.jpg
Image06192013213317.jpg
//Program for this project
int segmentPins[] = { 2, 3, 4, 5, 6, 7, 8, 9 };
int displayPins[] = {10};
int buttonPin = 11;
byte digits[10][8] = {
// a b c d e f g .
{ 1, 1, 1, 1, 1, 1, 0, 0}, // 0
{ 0, 1, 1, 0, 0, 0, 0, 0}, // 1
{ 1, 1, 0, 1, 1, 0, 1, 0}, // 2
{ 1, 1, 1, 1, 0, 0, 1, 0}, // 3
{ 0, 1, 1, 0, 0, 1, 1, 0}, // 4
{ 1, 0, 1, 1, 0, 1, 1, 0}, // 5
{ 1, 0, 1, 1, 1, 1, 1, 0}, // 6
{ 1, 1, 1, 0, 0, 0, 0, 0}, // 7
{ 1, 1, 1, 1, 1, 1, 1, 0}, // 8
{ 1, 1, 1, 1, 0, 1, 1, 0} // 9
};
void setup()
{
for (int i=0; i < 8; i++)
{
pinMode(segmentPins[i], OUTPUT);
}
pinMode(displayPins[0], OUTPUT);
pinMode(displayPins[0], OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
static int dice;
if (digitalRead(buttonPin))
{
dice = random(1,7);

}
updateDisplay(dice);
}
void updateDisplay(int value1)
{
digitalWrite(displayPins[0], HIGH);
digitalWrite(displayPins[1], LOW);
setSegments(value1);
delay(5);
digitalWrite(displayPins[0], LOW);
digitalWrite(displayPins[1], HIGH);
delay(5);
}
void setSegments(int n)
{
for (int i=0; i < 8; i++)
{
digitalWrite(segmentPins[i], ! digits[n][i]);
}
}
//You only do copy and paste if you exactly follow this project even this note

Now, a Program for Generating Random Numbers From 0-9

Image07092013170535.jpg
Image07092013170603.jpg
Image07092013170959.jpg
Image07092013171018.jpg
Image07092013171134.jpg
Image07092013171232.jpg
Image07092013171535.jpg
Image07092013171543.jpg
Image07092013171628.jpg
Image07092013170720.jpg
//Program for Generating Random Numbers from 0—9 (Blue) 
// Note: If you project stops of working, you can push the button of your arduino's switch for initializing newly
int segmentPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
int displayPins[] = {10};
int buttonPin = 11;
byte digits[10][8] = {
// a b c d e f g .
{ 1, 1, 1, 1, 1, 1, 0, 0}, // 0
{ 0, 1, 1, 0, 0, 0, 0, 0}, // 1
{ 1, 1, 0, 1, 1, 0, 1, 0}, // 2
{ 1, 1, 1, 1, 0, 0, 1, 0}, // 3
{ 0, 1, 1, 0, 0, 1, 1, 0}, // 4
{ 1, 0, 1, 1, 0, 1, 1, 0}, // 5
{ 1, 0, 1, 1, 1, 1, 1, 0}, // 6
{ 1, 1, 1, 0, 0, 0, 0, 0}, // 7
{ 1, 1, 1, 1, 1, 1, 1, 0}, // 8
{ 1, 1, 1, 1, 0, 1, 1, 0} // 9
};
void setup()
{
for (int i=0; i < 11; i++)
{
pinMode(segmentPins[i], OUTPUT);
}
pinMode(displayPins[0], OUTPUT);
pinMode(displayPins[0], OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
static int count;
if (digitalRead(buttonPin))
{
count = random(0,10);
}
updateDisplay(count);
}
void updateDisplay(int value1)
{
digitalWrite(displayPins[0], HIGH);
digitalWrite(displayPins[1], LOW);
setSegments(value1);
delay(5);
digitalWrite(displayPins[0], LOW);
digitalWrite(displayPins[1], HIGH);
delay(5);
}
void setSegments(int n)
{
for (int i=0; i < 11; i++)
{
digitalWrite(segmentPins[i], ! digits[n][i]);
}
}

And a Program for Generating Thirteen Random Letters From A-U

Image07092013174156.jpg
Image07092013174204.jpg
Image07092013174220.jpg
Image07092013174228.jpg
Image07092013174252.jpg
Image07092013174311.jpg
Image07092013174319.jpg
Image07092013174329.jpg
Image07092013174348.jpg
Image07092013174404.jpg
Image07092013174439.jpg
Image07092013174449.jpg
Image07092013174530.jpg
//Program for Generating Thirteen Random Letters from A—U (Blue) 
int segmentPins[] = {2, 3, 4, 5, 6, 7, 8, 9};
int displayPins[] = {10};
int buttonPin = 11;
byte digits[13][8] = {
// a b c d e f g .
{ 1, 1, 1, 0, 1, 1, 1, 0}, // A
{ 0, 0, 1, 1, 1, 1, 1, 0}, // b
{ 0, 0, 0, 1, 1, 0, 1, 0}, // c
{ 0, 1, 1, 1, 1, 0, 1, 0}, // d
{ 1, 0, 0, 1, 1, 1, 1, 0}, // E
{ 1, 0, 0, 0, 1, 1, 1, 0}, // F
{ 0, 1, 1, 0, 1, 1, 1, 0}, // H
{ 0, 0, 0, 0, 1, 1, 0, 0}, // I
{ 0, 1, 1, 1, 1, 0, 0, 0}, // J
{ 0, 0, 0, 1, 1, 1, 0, 0}, // L
{ 1, 1, 1, 1, 1, 1, 0, 0}, // O
{ 1, 1, 0, 0, 1, 1, 1, 0}, // P
{ 0, 1, 1, 1, 1, 1, 0, 0} // U
};
void setup()
{
for (int i=0; i < 14; i++)
{
pinMode(segmentPins[i], OUTPUT);
}
pinMode(displayPins[0], OUTPUT);
pinMode(displayPins[0], OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop()
{
static int count;
if (digitalRead(buttonPin))
{
count = random(0,13);
}
updateDisplay(count);
}
void updateDisplay(int value1)
{
digitalWrite(displayPins[0], HIGH);
digitalWrite(displayPins[1], LOW);
setSegments(value1);
delay(5);
digitalWrite(displayPins[0], LOW);
digitalWrite(displayPins[1], HIGH);
delay(5);
}
void setSegments(int n)
{
for (int i=0; i < 14; i++)
{
digitalWrite(segmentPins[i], ! digits[n][i]);
}
}