You have no items in your shopping cart.

Subtotal: 0.00

How to Interface 7SEG with 8051 Advanced Development Board

8051 Advanced Development Board

The 8051 Advanced Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Advanced Development Board Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

Seven Segment Display

A seven segment display is the most basic electronic display device that can display digits from 0-9. The most common configuration has an array of eight LEDs arranged in a special pattern to display these digits. They are laid out as a squared-off figure ‘8’. Every LED is assigned a name from 'a' to 'h' and is identified by its name. Seven LEDs 'a' to 'g' are used to display the numerals while eighth LED 'h' is used to display the dot/decimal.

Interfacing I2C - Seven Segment Display

Fig. 1 shows how to interface the seven segments with microcontroller. Seven segments are generally available in ten pin package. While eight pins correspond to the eight LEDs, the remaining two pins (at middle) are common and internally shorted. These segments come in two configurations, namely, Common cathode (CC) and Common anode (CA). In CC configuration, the negative terminals of all LEDs are connected to the common pins. The common is connected to ground and a particular LED glows when its corresponding pin is given high. In CA arrangement, the common pin is given a high logic and the LED pins are given low to display a number.



Fig. 1 Interfacing I2C - 7segment to Microcontroller

 

Interfacing Seven Segment with 8051

We now want to display a four digit number in 8051 Advanced Development Board by using seven segment displays. The seven segment display is connected with 801 controllers.

In 8051 Advanced Development Board Kit, 4 nos. of common anode seven segment displays are controlled I/O Lines (p1.0-p1.7).The 7-segmend display is powered from the 5V power supply enabled by switch SW30.

Pin Assignment with 8051

 

 

7-SEG

8051 Pins

7-Segment Display

Digit select lines

Digit - 1

P3.4





Digit – 2

P3.5

Digit – 3

P3.6

Digit - 4

P3.7

Segment Lines

Seg - a

P1.0

Seg – b

P1.1

Seg – c

P1.2

Seg – d

P1.3

Seg – e

P1.4

Seg – f

P1.5

Seg – g

P1.6

Seg – dp

P1.7

 

Make switch SW30 to ‘7SEG’ label marking position





 



Circuit Diagram to Interface 7 seg with 8051





Source Code

The Interfacing seven segment displays with 8051 program is very simple and straight forward that display a four digit number in seven segment displays by using I/O Lines. The C programs are developed in Keil software.

C Program to 7 Segment Display using 8051

***************************************************************************************

Title : Program to I2C - Seven Segment display

***************************************************************************************

#include

#include

unsigned char SetDisplay(unsigned char);

void delay();

sbit eseg1000 = P3^7;

sbit eseg100 = P3^6;

sbit eseg10 = P3^5;

sbit eseg1 = P3^4;

unsigned char d0,d1,d2,d3;

unsigned char SetDisplay(unsigned char value)

{

unsigned char segment[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x83,0xf8,0x80,0x98}; if(value<=10) return segment[value]; else return 0;

}

//--------------

//Delay Function

//--------------

void delay()

{

int i;

for(i=0; i<500; i++)

i = i + 0;

}

//--------------

//Main Program

//--------------

void main(void)

{

unsigned char count = 0;

unsigned long timer = 0;

int turn = 1;

P2 = 0xff;

while(1)

{

if(turn==1)

//7-Seg Display 0

{

eseg1000=0;

eseg100=0;

eseg10=0;

eseg1=1;

P2=SetDisplay(d0);

turn = 2;

delay();

}

else if(turn==2)

//7-Seg Display 1

{

eseg1=0;

eseg1000=0;

eseg100=0;

eseg10=1;

P2=SetDisplay(d1);

turn = 3;

delay();

}

else if(turn==3)

//7-Seg Display 2

{

eseg10=0;

eseg1=0;

eseg1000=0;

eseg100=1;

P2=SetDisplay(d2);

turn = 0;

delay();

}

else

//7-Seg Display 3

{

eseg100=0;

eseg10=0;

eseg1=0;

eseg1000=1;

P2=SetDisplay(d3);

turn = 1;

delay();

}

if(timer == 100)

{

d0++;

timer=0;

if(d0>=10)

{

d0=0;

d1++;

if(d1>=10)

{

d1=0;

d2++;

if(d2>=10)

{

d2=0;

d3++;

if(d3>=10)

{

d3=0;

}

}

}

}

}

timer++;

}

}