请问有基于单片机的八路抢答器的课程设计吗? 急需,希望能得到帮助,谢谢

2024-12-04 17:49:57
推荐回答(1个)
回答1:

哦 我这有一个很简单的程序 只是抢答功能这一块 你看下吧

/**********
八路抢答器的设计******/

#include

unsigned char code s8[16]={0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80};
sbit K1=P1^0;
sbit K2=P1^1;
sbit K3=P1^2;
sbit K4=P1^3;
sbit K5=P1^4;
sbit K6=P1^5;
sbit K7=P1^6;
sbit K8=P1^7;
sbit beep=P3^7;
sbit RST=P3^6;

void delay1ms(unsigned int i)
{
unsigned char j;
while(i--)
{
for(j=0;j<125;j++);
}
}
void main()
{

beep=1;
if(RST==0) P2=0xff;
if (K1==0) {P2=s8[0];beep=0;}
else if (K2==0) {P2=s8[1]; beep=0;}
else if (K3==0) {P2=s8[2]; beep=0;}
else if (K4==0) {P2=s8[3]; beep=0;}
else if (K5==0) {P2=s8[4]; beep=0;}
else if (K6==0) {P2=s8[5]; beep=0;}
else if (K7==0) {P2=s8[6]; beep=0;}
else if (K8==0) {P2=s8[7]; beep=0;}
else P0=0xff;
}