#include
#include
#define LED7 XBYTE[0x9f00]
#define LED6 XBYTE[0x9f01]
#define LED5 XBYTE[0x9f02]
#define LED4 XBYTE[0x9f03]
#define LED3 XBYTE[0x9f04]
#define LED2 XBYTE[0x9f05]
#define LED1 XBYTE[0x9f06]
#define LED0 XBYTE[0x9f07]
sbit p27=P2^7;
sbit p26=P2^6;
sbit p25=P2^5;
sbit d0=P0^0;
sbit d1=P0^1;
#define uint unsigned int
#define uchar unsigned char
uint t[]= //数码显示表(89c52)
{
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x40
};
void init()
{
LED7=t[0];
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void keyscan()
{
p27=1;
p26=0;
p25=1;
if(d0==0)
{
delay(5);
if(d0==0)
LED7=t[1];
delay(500);
}
if(d1==0)
{
delay(5);
if(d1==0)
LED7=t[2];
delay(500);
}
}
void main()
{
while(1)
{
init();
keyscan();
}
}
阅读(451) | 评论(0) | 转发(0) |