这是源程序:
#include "reg52.h"
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66};
void delay()
{uchar i,j;
for(i=0;i<255;i++)
for(j=0;j<255;j++);
}
uchar keyscan()
{uchar keyv,temp;
keyv=0;
P2=0xff;
temp=P2;
if(~(P2&temp))
{switch(temp)
{case 0xfe:
keyv=1;break;
case 0xfd:
keyv=2;break;
case 0xfb:
keyv=3;break;
case 0xf7:
keyv=4;break;
default:
keyv=0;break;
}
}
return keyv;
}
void main ()
{
unsigned char leds;
while(1)
{leds=keyscan();
P1=table[leds];
delay();
}
}
小弟在线等......
-
程序是用KEIL编写的,然后写到PROTEUS中AT89C52中,仿真后,数码管不亮。这是开关状态 检测电路。功能是按下几号开关,数码管就应该现实几,没键按下或者有多个键同时按下时显示0.为什么数码管怎么都不亮
一周热门 更多>