|
#include<reg52.h>
#define uint unsigned int
char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void disp_7seg(int num)
{
P1=0xFE;
P2=table[1];
delay(255);
P1=0xFD;
P2=table[2];
delay(255);
P1=0xFB;
P2=table[3];
delay(255);
P1=0xF7;
P2=table[4];
delay(255);
P1=0xFE;
P2=table[5];
delay(255);
P1=0xFD;
P2=table[6];
delay(255);
P1=0xFB;
P2=table[7];
delay(255);
P1=0xF7;
P2=table[8];
delay(255);
P1=0xFE;
P2=table[9];
delay(255);
}
void main()
{
while(1)
{
disp_7seg(123456789);
}
}
|
|