/*本程序实现:P2口接1*8键盘输入P0口接1*8led输出,按键则对应亮*/
#include"reg51.h"
/*1ms延时子程序*/
void mDelay(unsigned int i)
{
unsigned int j;
for(;i>0;i--)
for(j=0;j<125;j++);
}
/*main主程序*/
void main()
{
unsigned char key;
P2=0xff;
while(1)
{
P0=0xff;
key=P2;
if(key!=0xff)
{
mDelay(5);
P0=key;
mDelay(10);
}
}
}