Multiple 7 Segment LED display interfacing
Many electronic devices use two or more than two seven segment displays to display their output. The two seven segment displays can be connected in two ways. One way is to connect the two displays to the two ports of the microcontroller. However this is not a good way, as this will block all the ports and we cannot use microcontroller for any other purpose.
To overcome this problem, we use multiplexing of seven segment display. In multiplexing we use the concept of persistence of vision i.e., human brain cannot differentiate between two events occurring at a time difference of less than .04 sec. In this case the two digits are displayed one after the other so fast that the human brain cannot detect the difference. Although only one digit is displayed at a time it appears as a two digit number.
The circuit presented here demonstrates the above principle in form of a counter which counts from 0 to 99 with a small delay.
![]() |
| Schematic diagram for interfacing multiple 7 segment LED display. |
The two seven segments are connected as shown in the circuit diagram. The ‘a’ to ‘g’ pins of all the segments are interconnected to each other and connected to the data port P2 of the microcontroller. All the ‘a’ pins are connected to the pin P2.0, ‘b’ to P2.1 and so on. The four control pins from the controller AT89C51 are connected to the two pins of the port P1 as per the diagram.
The control pins are used to enable the seven segments. Whenever a high is given to any of the control pin, the corresponding seven segment gets activated. As a result the data corresponding to the first digit is sent on the port P2, which gets displayed. To display the next digit, the next seven segment is activated and the corresponding data is loaded on port P2. Similarly the third and two digits are displayed and the process keeps repeating.
C- Programing Code for this Project is given Below:
#include<reg51.h>
unsigned int digi_val[10]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10}; // Hex value corresponding to the digits 0 to 9
sbit seg1_pin = P0^0; // Enable pin to enable the seven segment 1.
sbit seg2_pin = P0^1; // Enable pin to enable the seven segment 2.
void delay(int l) // Time delay function
{
int i,j;
for(i=0;i<l;i++)
for(j=0;j<1275;j++);
}
int main(void)
{
int k=0,m=0,r=0,t;
for(k=0;k<10;k++)
{
for(m=0;m<10;m++)
{
for(t=0;t<25;t++)
{
seg1_pin=1;
P2=digi_val[k];
delay(1);
seg1_pin=0;
seg2_pin=1;
P2=digi_val[m];
delay(1);
seg2_pin=0;
}
}
}
}
