#define uchar unsigned char
#define uint unsigned int
uchar code table[]=
{
0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f,
}
sbit key1=P3^4
uchar num=0
void delay(uint z)
void main()
{
while(1)
{
P2=0xfe
P0=table[num]
delay(50)
if(key1==0)
{
while(!key1)
num++
}
if(num==10)
{
num=0
}
}
}
void delay(uint z)
{
while(z--)
}
sbit KEY = P0^1sbit LED = P0^2
int keyscan(void)
{
bit keyval=0
if(KEY)
{
delay(30)//延时消抖
if(KEY)
{
keyval = ~keyval//值取反
if(keyval )
{
LED = 1//led亮
}
else
{
LED = 0//led灭
}
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)