# include<reg52.h>
# define uchar unsigned char
# define uint unsigned int
sbit key1 = P3^2;
sbit key2 = P3^3;
sbit smg0 = P2^0;
sbit smg1 = P2^1;
sbit smg2 = P2^2;
sbit smg3 = P2^3;
uchar i = 0;
void delay_ms(uint ms)
{
uint x,y;
for(x=ms;x>0;x--)
for(y=120;y>0;y--);
}
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
void display()
{
smg1 = 1;
smg2 = 1;
smg3 = 1;
if (key1 == 0)
{
for(i=0;i<16;i++)
{
smg0 = 0;
P0 = table[i];
delay_ms(1000);
}
}
void main()
{
while(1)
{
display();
}
}
|