Professional Documents
Culture Documents
Contents at a Glance
8051 Primer Board ...........................................................3
I2C (Inter Integrated Circuit) . Error! Bookmark not defined.
Seven Segment Display ....................................................3
Interfacing Seven Segment Display ..................................4
Interfacing Seven Segment with 8051 ..............................5
Pin Assignment with 8051 ................................................6
Circuit Diagram to Interface 7 seg with 8051 ....................7
Source Code ....................................................................7
C Program to 7 Segment Display using 8051 .....................8
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
Join the Technical Community Today!
http://www.pantechsolutions.net
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
7-SEG
8051 Pins
Digit - 1
P3.4
Digit 2
P3.5
Digit 3
P3.6
Digit - 4
P3.7
Seg - a
P1.0
VCC
2
3
Digit - 1
1K
Segment Lines
P1.2
Seg d
P1.3
Seg e
P1.4
Seg f
g b
e d c
P1.5
Seg g
P1.6
Seg dp
P1.7
seg-a
Seg-b
Seg-c
seg-d
seg-e
seg-f
seg-g
seg--dp
7
6
4
2
1
9
10
5
A
B
C
D
E
F
G
DP
U1
7 SEG DISP
+5V
SW30
CA
Seg c
CA
P1.1
Seg b
7-Segment Display
OFF 1
2
3
4
8 ON
7
6
5
7SEG
LCD
SM/RL
GLCD
PWR ON/OFF
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.
= P3^4;
//-------------//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;
P1=SetDisplay(d0);
turn = 2;
delay();
}
else if(turn==2)
//7-Seg Display 1
{
eseg1=0;
eseg1000=0;
eseg100=0;
eseg10=1;
P1=SetDisplay(d1);
turn = 3;
delay();
}
else if(turn==3)
//7-Seg Display 2
{
eseg10=0;
eseg1=0;
eseg1000=0;
eseg100=1;
P1=SetDisplay(d2);
turn = 0;
delay();
}
else
//7-Seg Display 3
{
eseg100=0;
eseg10=0;
eseg1=0;
eseg1000=1;
P1=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++;
}
}
What do we sell?
Our products range from Various Microcontroller
development boards, DSP Boards, FPGA/CPLD boards,
Communication Kits, Power electronics, Basic electronics,
Robotics, Sensors, Electronic components and much more . Our
goal is to make finding the parts and information you need
easier and affordable so you can create awesome projects and
training from Basic to Cutting edge technology.