#include <reg51.h>
void delay(unsigned char i)
{
unsigned char j,k;
for(j = 0; j < 255; j++)
{
for(k = 0; k < i; k++)
{
;
}
}
}
void main(void)
{
unsigned char flag = 0;
P1 = 0xff;
while(1)
{
switch(P2)
{
case 0xfe:
{
if(flag == 0)
{
P1 = 0xc0;
flag = 1;
}
break;
}
case 0xfd:
{
if(flag == 1)
{
P1 = 0xf9;
flag = 0;
}
break;
}
case 0xfb:
{
if(flag == 1)
{
P1 = 0xa4;
flag = 0;
}
break;
}
case 0xf7:
{
if(flag == 1)
{
P1 = 0xb0;
flag = 0;
}
break;
}
case 0xef:
{
if(flag == 1)
{
P1 = 0x99;
flag = 0;
delay(10000);
P1 = 0xff;
}
break;
}
case 0xdf:
{
if(flag == 1)
{
P1 = 0x92;
flag = 0;
}
break;
}
case 0xbf:
{
if(flag == 1)
{
P1 = 0x82;
flag = 0;
}
break;
}
case 0x7f:
{
if(flag == 1)
{
P1 = 0xf8;
flag = 0;
}
break;
}
}
}
}
简单的抢答器设计(89c52RC)
最新推荐文章于 2022-05-17 21:38:12 发布