Seven Segment Display With Arduino
PROGRAMMING 4 DIGIT 7 SEGMENT LED
DISPLAY
INTRODUCTION:
Today we see how 7 segments LED display work. It is somewhat like a digital clock and also that type of watch we all see at Railway Station.
COMPONENTS::
- Arduino UNO.
- 7 segment led display
- jumper wire.
- bread board.
- resistor.
7-segment display is an 8-shaped component which packages 7 LEDs.Each LED is called a segment -When energized,one segment forms part of a numeral (both decimal and hexadecimal) to be displayed.An additional 8th LEDs is something used within the same package thus allowing the indication of a decimal point (DP) when two or more 7-segment displays are connected together to displays number greater than ten.
code:
int a=6; //for displaying segment "a"
int b=5; //for displaying segment "b"
int c=10; //for displaying segment "c"
int d=9; //for displaying segment "d"
int e=8; //for displaying segment "e"
int f=7; //for displaying segment "f"
int g=4; //for displaying segment "g"
void setup() {
// put your setup code here, to run once:
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
pinMode(g,OUTPUT);
}
void loop() {
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for one
digitalWrite(b,LOW);digitalWrite(c,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for two
digitalWrite(a,LOW);digitalWrite(b,LOW);
digitalWrite(g,LOW);
digitalWrite(e,LOW);digitalWrite(d,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for three
digitalWrite(a,LOW);digitalWrite(b,LOW);
digitalWrite(g,LOW);digitalWrite(c,LOW);
digitalWrite(d,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for four
digitalWrite(f,LOW);digitalWrite(g,LOW);
digitalWrite(b,LOW);digitalWrite(c,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for five
digitalWrite(a,LOW);digitalWrite(f,LOW);
digitalWrite(g,LOW);digitalWrite(c,LOW);
digitalWrite(d,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for six
digitalWrite(a,LOW);digitalWrite(f,LOW);
digitalWrite(e,LOW);digitalWrite(d,LOW);
digitalWrite(c,LOW);digitalWrite(g,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for seven
digitalWrite(a,LOW);digitalWrite(b,LOW);
digitalWrite(c,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for eight
digitalWrite(a,LOW);digitalWrite(b,LOW);
digitalWrite(c,LOW);digitalWrite(d,LOW);
digitalWrite(e,LOW);digitalWrite(f,LOW);digitalWrite(g,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
//for nine
digitalWrite(f,LOW);digitalWrite(a,LOW);
digitalWrite(b,LOW);digitalWrite(g,LOW);
digitalWrite(c,LOW);digitalWrite(d,LOW);
delay(1000);
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
}
here, we can see how 7-segment display work I do my connection according to it.....for example, I connect LED pin a with digital pin 6 and similarly b with digital pin 5....in this way we connect all the 7-segment display LED with Arduino UNO. and we can see in our code whatever number we can we only "LOW" that pin for example to display 7 no. LED we low (a,b,c)pin. we give a delay for rest when the number shown after 1 sec next number will be shown .we can increase the delay's time.
CIRCUIT:
7
Comments
Post a Comment