#include <reg52.h>
sbit key=P1^1;
unsigned char code ledchar[]={0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
void Delays ();
void main ()
{
unsigned char cnt=0;
bit backup=1;
bit keyup=1;
P0=ledchar[cnt];
while (1)
{
P0=ledchar[cnt];
keyup=key;
if(keyup!=backup)
{
Delays ();
if(keyup==key)
{
if(backup==0)
{
cnt++;
if(cnt>=10)
cnt=0;
}
P0=ledchar[cnt];
}
}
backup=key;
}
}
void Delays()
{
unsigned int i = 1000;
while(i--);
}
有的时候需要按三四次才能变数
一周热门 更多>