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
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.
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
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
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.
Important note: it's not 2N3904 but 2N3906 the transistor used in this project.
Downloads
Install the Pins
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
In this step, install the LED display and its resistors of 200 ohm.
Install the Transistor, Switch and Resistors
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
//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
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
//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]);
}
}
// 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
//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]);
}
}
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]);
}
}