Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

7 Segment Display :

Seven segment displays are the output display device that provides a way to
display information in the form of images or text or decimal numbers which
is an alternative to the more complex dot matrix displays. It is widely used in
digital clocks, basic calculators, electronic meters, and other electronic
devices that display numerical information. It consists of seven segments of
light-emitting diodes (LEDs) which are assembled like numerical 8.

Types of 7 Segment Display:


When it comes to types of this display, two are available. Which are;
• The Common Anode(CA) 7 Segment Display
• The Common Cathode(CC) 7 Segment Display

7 Segment Display Common Cathode:

In this type, all LEDs share a common cathode terminal while each
anode terminal is connected to a different segment. In order for a
segment to light up, the corresponding anode terminal will be provided
with +5V source voltage and the common cathode terminal will be
grounded. To interface a common anode type to a microcontroller then
the Anodes of each segment are connected through appropriate port
pins of the microcontroller. When we want to turn on any particular
segment then we need to apply logic high on the corresponding anode.
7 Segment Display Common Anode:

In this type, all LEDs share a common anode terminal while each
cathode terminal is connected to a different segment. In order for a
segment to light up, the corresponding cathode terminal will be
grounded and the common anode terminal is provided with +5V source
voltage. To interface a common anode type to a microcontroller then
the Cathodes of each segment are connected through appropriate port
pins of the microcontroller. When we want to turn on any particular
segment then we need to apply logic zero on the corresponding
cathode.
Depending upon the decimal digit to be displayed, the particular set of LEDs is
forward biased. For instance, to display the numerical digit 0, we will need to
light up six of the LED segments corresponding to a, b, c, d, e and f. Thus the
various digits from 0 through 9 can be displayed using a 7-segment display as
shown.

7-segment Display Truth Table:


Write a program to control keypad using Arduino UNO
THE CODE FOR A 3X4 KEYPAD

#include <Keypad.h>

const byte ROWS = 4;


const byte COLS = 3;

char hexaKeys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};

byte rowPins[ROWS] = {9, 8, 7, 6};


byte colPins[COLS] = {5, 4, 3};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys),


rowPins, colPins, ROWS, COLS);

void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();

if (customKey){
Serial.println(customKey);
}
}
Traffic light system using Arduino and 7-
Segment Display:
void displaysegmen (int x);
void setup()
{
pinMode(13, OUTPUT); //Segmen A
pinMode(12, OUTPUT); //Segmen B
pinMode(11, OUTPUT); //Segmen C
pinMode(10, OUTPUT); //Segmen D
pinMode(9, OUTPUT); //Segmen E
pinMode(8, OUTPUT); //Segmen F
pinMode(7, OUTPUT); //Segmen G
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
pinMode(1, OUTPUT);
}
void loop() {
digitalWrite(1,0);
digitalWrite(2,0);
digitalWrite(3,1);
displaysegmen(9); delay(1000);
displaysegmen(8); delay(1000);
displaysegmen(7); delay(1000);
displaysegmen(6); delay(1000);
displaysegmen(5); delay(1000);
displaysegmen(4); delay(1000);
displaysegmen(3); delay(1000);
displaysegmen(2); delay(1000);
displaysegmen(1); delay(1000);
//
digitalWrite(1,0);
digitalWrite(2,1);
digitalWrite(3,0);
displaysegmen(3); delay(1000);
displaysegmen(2); delay(1000);
displaysegmen(1); delay(1000);
//
digitalWrite(1,1);
digitalWrite(2,0);
digitalWrite(3,0);
displaysegmen(9); delay(1000);
displaysegmen(8); delay(1000);
displaysegmen(7); delay(1000);
displaysegmen(6); delay(1000);
displaysegmen(5); delay(1000);
displaysegmen(4); delay(1000);
displaysegmen(3); delay(1000);
displaysegmen(2); delay(1000);
displaysegmen(1); delay(1000);
}
void displaysegmen (int x) {
switch (x) {
case 1:
digitalWrite(13,LOW); digitalWrite(12,HIGH);
digitalWrite(11,HIGH); digitalWrite(10,LOW);
digitalWrite(9,LOW); digitalWrite(8,LOW);
digitalWrite(7,LOW); break;
case 2:
digitalWrite(13,HIGH); digitalWrite(12,HIGH);
digitalWrite(11,LOW); digitalWrite(10,HIGH);
digitalWrite(9,HIGH); digitalWrite(8,LOW);
digitalWrite(7,HIGH); break;
case 3:
digitalWrite(13,HIGH); digitalWrite(12,HIGH);
digitalWrite(11,HIGH); digitalWrite(10,HIGH);
digitalWrite(9,LOW); digitalWrite(8,LOW);
digitalWrite(7,HIGH); break;
case 4:
digitalWrite(13,LOW); digitalWrite(12,HIGH);
digitalWrite(11,HIGH); digitalWrite(10,LOW);
digitalWrite(9,LOW); digitalWrite(8,HIGH);
digitalWrite(7,HIGH); break;
case 5:
digitalWrite(13,HIGH); digitalWrite(12,LOW);
digitalWrite(11,HIGH); digitalWrite(10,HIGH);
digitalWrite(9,LOW); digitalWrite(8,HIGH);
digitalWrite(7,HIGH); break;
case 6:
digitalWrite(13,HIGH); digitalWrite(12,LOW);
digitalWrite(11,HIGH); digitalWrite(10,HIGH);
digitalWrite(9,HIGH); digitalWrite(8,HIGH);
digitalWrite(7,HIGH); break;
case 7:
digitalWrite(13,HIGH); digitalWrite(12,HIGH);
digitalWrite(11,HIGH); digitalWrite(10,LOW);
digitalWrite(9,LOW); digitalWrite(8,LOW);
digitalWrite(7,LOW); break;
case 8:
digitalWrite(13,HIGH); digitalWrite(12,HIGH);
digitalWrite(11,HIGH); digitalWrite(10,HIGH);
digitalWrite(9,HIGH); digitalWrite(8,HIGH);
digitalWrite(7,HIGH); break;
case 9:
digitalWrite(13,HIGH); digitalWrite(12,HIGH);
digitalWrite(11,HIGH); digitalWrite(10,HIGH);
digitalWrite(9,LOW); digitalWrite(8,HIGH);
digitalWrite(7,HIGH); break;
}
}

You might also like