Lab No. 5 Seven Segment Display Interfacing: Objectives
Lab No. 5 Seven Segment Display Interfacing: Objectives
Introduction:
A seven segment display, as its name indicates, is composed of seven elements. Individually on
or off, they can be combined to produce simplified representations of the numerals. A single LED
is used inside one segment to radiate light through it.
If cathodes of all the LEDs are common, this type of display is called common cathode and for
common anode type display, anode of all LEDs are common and connected to the common pin.
Multiplexing:
Multiplexing is required when we want to interface more than one displays with microcontroller. If
we interface them normally, they will require lots of I/O ports. In multiplexing, only one display is
kept active at a time but we see all of them active. For multiplexing all the displays are connected
in parallel such that if you activate any segment, say ‘a’ the ‘a’ segment of all displays glows up.
But we can switch ON and OFF the “common” line of the displays with the Microcontroller pins.
So if we wish to light up the ‘a’ segment of display 1 we simply switch on display 2 first by applying
ground level (for common cathode display) at the common pin of the display and then send a high
signal on the I/O pin connected to segment ‘a’ to lit it.
Page 5
Microprocessors and Microcontrollers Lab 5
a
_____
f | g | b
|_____|
e | | c dot
|_____| .
d
______________________________
|No.| . g f e d c b a
|____________________________
| 0 | 0 0 1 1 1 1 1 1 = 0x3F |
| 1 | 0 0 0 0 0 1 1 0 = 0x06 |
| 2 | 0 1 0 1 1 0 1 1 = 0x5B |
| 3 | 0 1 0 0 1 1 1 1 = 0x4F |
| 4 | 0 1 1 0 0 1 1 0 = 0x66 |
| 5 | 0 1 1 0 1 1 0 1 = 0x6D |
| 6 | 0 1 1 1 1 1 0 1 = 0x7D |
| 7 | 0 0 0 0 0 1 1 1 = 0x07 |
| 8 | 0 1 1 1 1 1 1 1 = 0x7F |
| 9 | 1 0 0 1 1 1 1 1 = 0x6F |
|____________________________
unsigned char Seven_Segment[]={0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D,0x7D, 0x07, 0x7F, 0x6F};
unsigned char i = 0;
void setup()
DDRD = 0xFF;
pinMode(8,HIGH);
pinMode(9,HIGH);
Page 6
Microprocessors and Microcontrollers Lab 5
void loop()
i++;
i = 0;
digitalWrite(8,LOW);
// Display units
PORTD=Seven_Segment[units];
delay(500);
digitalWrite(9,LOW);
// Display tens
PORTD= Seven_Segment[tens];
delay(500);
Page 7
Microprocessors and Microcontrollers Lab 5
Schematic:
Lab Task:
Show hexadecimal numbers from 00 to FF on two seven segment display
Page 8