You are on page 1of 2

Code 3: Single Seven Segment Interfacing

/* Details:-Single 7-segment
interface.
-This program count from 0 to 9 and
display it on 7 segment
-Sevent segment is connected to port
p0
-display0 can be activated by p1.0
pin, by setting it as high
-seven segment are commmon anode,
hence to active a segment
corresponding port pin must have to be
low.
A
---A->P0.0 B->P0.1 C->P0.2
F| G |B
D->P0.3 E->P0.4 F->P0.5
---G->P0.6 H->P0.7
E|
|C
---- . H
D
Author: Ravikant verma */

//7-seg code for 0-9


unsigned char
mynum[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82
,0xf8,0x80,0x90};
void main()
{
int z=0;
p1=0x01; //for selection of dis0 of
7-seg
while(1)
{
p0=mynum[z];
Delay_ms(1000);
z++ ;
if(z>9)
z=0;
}
}

// display on seven segment


// delay of 1000ms
//increment z
//check for z=9
//set again z=0

You might also like