求单片机3路抢答器程序
发布网友
发布时间:2022-04-25 01:27
我来回答
共2个回答
热心网友
时间:2023-10-19 13:06
你在放到单片机里面调试一下。
#include<reg52.h>
sbit k3 = P3^5;
sbit k4 = P3^4;
sbit k5 = P3^3;
sbit k6 = P3^2;
sbit s = P1^3;
sbit s1 = P1^0;
sbit s2 = P1^1;
sbit s3 = P1^2;
delay()
{
int i = 15000;
while(i--);
}
main()
{
if(k6 == 0 && k3 == 0)
for(;k6 = 1;)
{
s = 0;
s1 = 0;
delay();
s = 1;
s1 = 1;
delay();
s = 0;
s1 = 0;
delay();
s = 1;
s1 = 1;
delay();
for(;k6 = 1;)
{
s = ~s;
delay();
}
}
if(k6 == 0 && k4 == 0)
for(;k6 = 1;)
{
s = 0;
s2 = 0;
delay();
s = 1;
s2 = 1;
delay();
s = 0;
s2 = 0;
delay();
s = 1;
s2 = 1;
delay();
for(;k6 = 1;)
{
s = ~s;
delay();
}
}
if(k6 == 0 && k5 == 0)
for(;k6 = 1;)
{
s = 0;
s3 = 0;
delay();
s = 1;
s3 = 1;
delay();
s = 0;
s3 = 0;
delay();
s = 1;
s3 = 1;
delay();
for(;k6 = 1;)
{
s = ~s;
delay();
}
}
}
热心网友
时间:2023-10-19 13:07
求程序,没有编程语言的要求?