0% found this document useful (0 votes)
29 views8 pages

7 Segment CC

Uploaded by

Pranav R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views8 pages

7 Segment CC

Uploaded by

Pranav R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Arduino With 7 Segment display

 1 × Breadboard
 1 × Arduino Uno R3
 1 × 7-Segment Display CC
 220 to 1000Ω Resistor
 Jumper wire

What is a Seven Segment LED Display?

Seven Segment Display is an LED based display screen that can display information in
the form of decimal numbers. The seven segment display is a used in place of the more
complex dot matrix displays. It is called so because it consists of seven segments of light
emitting diodes (LEDs) that are assembled like decimal 8 as shown in the following
figure.

Seven segments LED display can be used in applications where an electronic display
device is required for showing decimal numbers from 0 to 9, sometimes, basic characters
as well. Since, it uses LEDs, therefore it is an energy efficient display device. Therefore, it
is most widely used in those devices that are powered by a small battery or a cell.
Working of Seven Segment LED Display
A seven segment display consists of seven LED segments arranged like a decimal 8.
These LED segments are illuminated to form a pattern that represents a decimal number
from 0 to 9. Now, let us understand, how the seven segment LED display work to display
different numbers.
 When power is given to all the segments and if we disconnect power from the
segment ‘g’, then it displays the decimal number 0.
 When the power is given to segments "b" and "c" only, then it displays the number
1.
 When the power is given to the segments "a", "b", "g", "e", "d", then it displays the
number 2.
 When the power is given to segments "a", "b", "g", "c", "d", then it displays the
number 3.
 When the power is given to segments "b", "c", "f", "g", then it displays the number
4.
 When the power is given to segments "a", "c", "d", "f", "g", then it displays the
number 5.
 When the power is given to segments "a", "c", "d", "e", "f", "g", then it displays the
number 6.
 When the power is given to segments "a", "b", "c", then it displays the number 7.
 When electrical energy is supplied to all the segments, then the seven segment LED
display shows the decimal number 8.
 When the power is given to segments "a", "b", "c", "d", "f", "g", then it displays the
number 9.
In this way, we can display any decimal number from 0 to 9 by illuminating a set of LED
segments of the seven segment LED display.

Types of Seven Segment LED Displays

There are two types of seven segment displays available −


Common Cathode(CC) Seven Segment Display
In this type of seven segment display, the cathode terminal of all LED segments are
connected together to logic 0 (lower voltage level). The logic 1 (higher voltage level) is
applied through a current limiting resistor to forward bias the individual LED segments at
their anode terminals.
Common Anode (CA)Seven Segment Display
In this type of seven segment LED display, the anode terminals of all the LED segments
are connected together to the logic 1 (higher voltage level), and the logic 0 (lower
voltage level) is used through a current limiting resistor to the individual cathode
terminals of LED segments.
Circuit Diagram for CC

Code for Display Digit 8


int a=2;
int b=3;
int c=4;
int d=5;
int e=6;
int f=7;
int g=8;
int dp=9;
void setup()
{
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(g,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(g,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
}

Code for Display Digits 0- 9


int a=2;
int b=3;
int c=4;
int d=5;
int e=6;
int f=7;
int g=8;
int dp=9;

void display1(void) //display number 1


{
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
}

void
display2(void) // display number 2
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(g,HIGH);
digitalWrite(e,HIGH);
digitalWrite(d,HIGH);
}
void display3(void) // display number3
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(g,HIGH);
}
void display4(void) // display number4
{
digitalWrite(f,HIGH);
digitalWrite(b,HIGH);
digitalWrite(g,HIGH);
digitalWrite(c,HIGH);

}
void display5(void) // display number 5

{
digitalWrite(a,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
}

void display6(void) // display number 6


{
digitalWrite(a,HIGH);
digitalWrite(f,HIGH);
digitalWrite(g,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
}
void display7(void) // display number 7
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
}

void display8(void) // display number 8


{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(g,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
}
void display9(void) // display number 9
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(g,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(f,HIGH);
}
void display0(void) // display number 0
{
digitalWrite(a,HIGH);
digitalWrite(b,HIGH);
digitalWrite(c,HIGH);
digitalWrite(d,HIGH);
digitalWrite(e,HIGH);
digitalWrite(f,HIGH);
}
void clearDisplay(void) // No digit Display off
{
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(g,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
}

void setup()
{
int i;
for(i=4;i<=11;i++)

pinMode(i,OUTPUT);
}
void loop()
{
while(1)

{
clearDisplay();
display0();
delay(2000);
clearDisplay();

display1();
delay(2000);
clearDisplay();
display2();
delay(2000);
clearDisplay();
display3();

delay(2000);
clearDisplay();
display4();
delay(2000);

clearDisplay();
display5();
delay(2000);
clearDisplay();

display6();
delay(2000);
clearDisplay();

display7();
delay(2000);
clearDisplay();
display8();

delay(2000);
clearDisplay();
display9();

delay(2000);
}
}

You might also like