i=2break
if(key==0)break250
sbit rstkey=P2^2/
case 0x08:break
case 0x04200j++)
default/
#define uchar unsigned char
uchar table[]={0x3f,0x4fbreak,0x06/
P2=0xff:i=8,0x6d:i=6
}
switch(key)
{
case 0x01,0x7f}i<
case 0x80reg51:i=7:i=1:i=3
void delay()/,0x66
case 0x40,0x7d:i=4break
}
P1=table[i]break
case 0x10:i=5,0x07,j
P1=table[i]break
while(1)
{
i=0j<break
case 0x02,0x5b延时约400毫秒
{
uchar i
for(i=0break
while(1)
{
key=P3,key
case 0x20i++)
for(j=0/.h>break否则蜂鸣器报警
delay()显示按下键号的LED
while(1)
{
if(rstkey==0)break/
sbit speaker=P2^0主持人按下复位键则重新开始
speaker=~speaker#include<显示按下抢答器的号
P0=key
}
main()
{
uchar i
就是一个逻辑问题了if qiangda==1 then
count--
if count<5
moudeng=1
fi
if !first||!second&&||!third||..
tingzhidaojishi=1
关闭中断
查询端口看看谁按的键
先来个汇编的程序,P1接一个共阳极数码管,P0低4位接4个抢答按键,主持人复位采用单片机复位按钮实现。ORG 0000H
START: MOV A,P0
ORL A,#0F0H
CJNE A,#0FFH,PL0
SJMP START
PL0: LCALL DELAY
MOV A,P0
ORL A,#0F0H
CJNE A,#0FFH,PL1
SJMP START
PL1:JNB ACC.0,K1
JNB ACC.1,K2
JNB ACC.2,K3
JNB ACC.3,K4
LJMP START
K1:MOV P1,#0F9H
SJMP $
K2:MOV P1,#0A4H
SJMP $
K3:MOV P1,#0B0H
SJMP $
K4:MOV P1,#99H
SJMP $
DELAY:MOV R6,#15
DEL2: MOV R7,#200
DJNZ R7,$
DJNZ R6,DEL2
RET
END
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)