电路功用:
电路可完成9路抢答器功用,一人按下后,其他人再按无效,需复位后方可从头抢答。
下图为Proteus仿真图:
下图为原理图:
下图为PCB图:
下图为实物图,手机拍照 ,不是很明晰
以下为源程序:
#include
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={ //不带小数点的数码管编码
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90};
uchar num;
sbit beep=P3^6;
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 k9=P3^0;
void keyscan();
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x–)
for(y=5000;y>0;y–);
}
void main()
{
while(1)
{
keyscan();
}
}
void keyscan()
{
P0=0xc0;
P2=0xfe;
if(k1==0)
{
beep=0;
delay(5);
beep=1;
P0=table[1];
delay(10000);
}
else if(k2==0)
{
beep=0;
delay(5);
beep=1;
P0=table[2];
delay(10000);
}
else if(k3==0)
{
beep=0;
delay(5);
beep=1;
P0=table[3];
delay(10000);
}
else if(k4==0)
{
beep=0;
delay(5);
beep=1;
P0=table[4];
delay(10000);
}
else if(k5==0)
{
beep=0;
delay(5);
beep=1;
P0=table[5];
delay(10000);
}
else if(k6==0)
{
beep=0;
delay(5);
beep=1;
P0=table[6];
delay(10000);
}
else if(k7==0)
{
beep=0;
delay(5);
beep=1;
P0=table[7];
delay(10000);
}
else if(k8==0)
{
beep=0;
delay(5);
beep=1;
P0=table[8];
delay(10000);
}
else if(k9==0)
{
beep=0;
delay(5);
beep=1;
P0=table[9];
delay(10000);
}
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/zhizao/261683.html