很久之前做的一个简单的抢答器系统
附有原理图以及相关的源程序
希望可以对感兴趣的人有帮助
可以对单片机有一定了解
Altium Designer画的原理图和PCB图如下:(51hei附件中可下载工程文件)
原理图
单片机源程序如下:
- P4 DATA 0C0H
- P5 DATA 0C8H
- MIAO EQU 32H
- SW1 BIT P1.0
- SW2 BIT P1.1
- SW3 BIT P1.2
- SW4 BIT P1.3
- SW5 BIT P1.4
- BEEP BIT P5.5
- LED1 BIT P3.4
- LED2 BIT P3.5
- LED3 BIT P4.5
- LED4 BIT P4.6
- LED5 BIT P4.7
-
- ORG 0000H ;
- AJMP MAIN
- ORG 000BH ;
- AJMP TIMER0
- ORG 0013H
- AJMP part_1
- ORG 0100H
- MAIN: MOV SP,#40H
- MOV TMOD,#01H ; T0?????1
- MOV TH0,#0E0H
- MOV TL0,#0C0H
- SETB TR0 ;??T0??
- SETB ET0 ;T0???
- SETB EX1
- SETB PX1
- SETB EA
-
- MOV MIAO,#09H ;CNT=09
- MOV P0,#90H
- MOV R3,#250 ;1s=250*4ms
- MOV P2,#0c0H ;DISPLAY 0
- AJMP $
-
- part_1:push ACC
- push PSW
- JNB SW1,SW1_OK
- JNB SW2,SW2_OK
- JNB SW3,SW3_OK
- JNB SW4,SW4_OK
- AJMP SW5_OK
- SW1_OK:LCALL DELAY
- CLR LED1
- MOV P2,#0F9H
- AJMP END_EXT1
-
- SW2_OK:LCALL DELAY
- CLR LED2
- MOV P2,#0A4H
- AJMP END_EXT1
-
- SW3_OK:LCALL DELAY
- CLR LED3
- MOV P2,#0B0H
- AJMP END_EXT1
-
- SW4_OK:LCALL DELAY
- CLR LED4
- MOV P2,#99H
- AJMP END_EXT1
-
- SW5_OK:LCALL DELAY
- CLR LED5
- MOV P2,#92H
-
- END_EXT1:CLR EX1
- CLR ET0
- CLR BEEP
- LCALL DELAY3S
- SETB BEEP
- POP PSW
- POP ACC
- RETI
-
- DELAY: MOV R5,#04 ;160ms
- DEL01: MOV R6,#200
- DEL02: MOV R7,#200
- DJNZ R7,$
- DJNZ R6,DEL02
- DJNZ R5,DEL01
- RET
-
- DELAY3S:MOV R4,#20
- WW: LCALL DELAY
- DJNZ R4,WW
- RET
- TIMER0:PUSH ACC
- PUSH PSW
- PUSH DPH
- PUSH DPL
- MOV TH0,#0E0H
- MOV TL0,#0C0H
- DJNZ R3,A2
- MOV R3,#250
- MOV A,MIAO
- DEC A
- MOV MIAO,A
- CJNE A,#0FFH,A2
- MOV MIAO,#00H
- CLR ET0
- CLR EX1
- CLR BEEP
- LCALL DELAY3S
- SETB BEEP
- A2:MOV A,MIAO
- MOV DPTR,#TAB_LED
- MOVC A,@A+DPTR
- MOV P0,A
- POP DPL
- POP DPH
- POP PSW
- POP ACC
- RETI
-
- TAB_LED:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H ;???????
- DB 90H,88H,83H,0C6H,0A1H,86H,8EH
-
- END
复制代码
所有资料51hei提供下载:
1.zip
(610.98 KB, 下载次数: 17)
|