#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
void delayms(uint xms);
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
int Count;
sbit KEY=P3^7;
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void main(void)
{
Count=0;
P0=table[Count/10];
P2=table[Count%10];
while(1)
{
if(KEY==0)
{
delayms(10);
if(KEY==0)
{
Count++;
if(Count==100)
{
Count=0;
}
P0=table[Count/10];
P2=table[Count%10];
while(KEY==0);
}
}
}
}
|