#include<reg51.h>
void delay(unsigned char);
sbit keyadd=P3^7;
sbit keysub=P3^6;
void main()
{
unsigned char count=90;
unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
int *p;
p=1000;
*p=10;
while(1)
{
if(keyadd==0){
delay(5);//
count=(++count%100);
while(keyadd==0);//
}
if(keysub==0){
delay(5);//
count=(--count%255);
while(keysub==0);//
}
P0=table[count/10];
P2=table[count%10];
}
}
void delay(unsigned char k)
{
for( ;k>0;k--);
}
|