<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機(jī)搶答器設(shè)計

          單片機(jī)搶答器設(shè)計

          作者: 時間:2013-01-15 來源:網(wǎng)絡(luò) 收藏

          ;=====正常搶答處理程序=====
          TRUE1: ACALL BARK ;按鍵發(fā)聲
          MOV A,R2
          MOV R6,A ;搶答時間R2送R6
          MOV R3,#01H
          CLR OK ;因為答題的計時不再查詢搶答,所以就鎖了搶答
          AJMP COUNT
          TRUE2: ACALL BARK;
          MOV A,R2
          MOV R6,A
          MOV R3,#02H
          CLR OK
          AJMP COUNT
          TRUE3: ACALL BARK;
          MOV A,R2
          MOV R6,A
          MOV R3,#03H
          CLR OK
          AJMP COUNT
          TRUE4: ACALL BARK;
          MOV A,R2
          MOV R6,A
          MOV R3,#04H
          CLR OK
          AJMP COUNT
          TRUE5: ACALL BARK;
          MOV A,R2
          MOV R6,A
          MOV R3,#05H
          CLR OK
          AJMP COUNT
          TRUE6: ACALL BARK;
          MOV A,R2
          MOV R6,A
          MOV R3,#06H
          CLR OK
          AJMP COUNT
          ;=====犯規(guī)搶答程序=====
          ERROR: MOV R0,#00H
          MOV TH1,#3CH
          MOV TL1,#0B0H
          MOV 34H,R3 ;犯規(guī)號數(shù)暫存與(34H)
          HERE: MOV A,R0
          CJNE A,#0AH,FLASH ;0.5s向下運(yùn)行->滅并停響
          CLR RING
          MOV R3,#0AH
          MOV R4,#0AH
          MOV R5,#0AH ;三燈全滅
          AJMP CHECK1
          FLASH: CJNE A,#14H,CHECK1 ;下面系1s的情況,響并顯示號數(shù)并清R0,重新計
          SETB RING
          MOV R0,#00H
          MOV R3,34H ;取回號數(shù)
          MOV R5,#0BH
          MOV R4,#0BH ;顯示FF和號數(shù)
          AJMP CHECK1
          CHECK1:JNB P1.7,QUIT1
          ACALL DISPLAY
          AJMP HERE
          QUIT1: CLR RING
          CLR OK
          AJMP START
          ;=====顯示程序=====
          DISPLAY:
          MOV DPTR,#DAT1 ;查表顯示程序,利用P0口做段選碼口輸出/P2低三位做位選碼輸出,
          MOV A,R5
          MOVC A,@A+DPTR
          MOV P2,#01H
          MOV P0,A
          ACALL DELAY
          MOV DPTR,#DAT2
          MOV A,R4
          MOVC A,@A+DPTR
          MOV P2,#02H
          MOV P0,A
          ACALL DELAY
          MOV A,R3
          MOVC A,@A+DPTR
          MOV P2,#04H
          MOV P0,A
          ACALL DELAY
          RET
          DAT1:DB 00H,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,00H,71H
          ;"滅","1","2","3","4","5","6","7","8","9","滅","F"
          DAT2:DB 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,00H,71H
          ;第一個為零,其他與上相同,因為十位如果為零顯示熄滅
          ;====加減時間延時(起到不會按下就加N個數(shù))======
          DELAY1: MOV 35H,#08H
          LOOP0: ACALL DISPLAY
          DJNZ 35H,LOOP0
          RET
          ;=====延時(顯示和去抖動用到)=====
          DELAY: MOV 32H,#12H
          LOOP: MOV 33H,#0AFH
          LOOP1: DJNZ 33H,LOOP1
          DJNZ 32H,LOOP
          RET
          ;=====發(fā)聲程序=====
          BARK: SETB RING
          ACALL DELAY1
          ACALL DELAY1
          CLR RING ;按鍵發(fā)聲
          RET
          ;=====TO溢出中斷(響鈴程序)=====
          T0INT: MOV TH0,#0ECH
          MOV TL0,#0FFH
          JNB RING,OUT;
          CPL P3.6 ;RING標(biāo)志位為1時候P3.6口不短取反使喇叭發(fā)出一定頻率的聲音
          OUT: RETI
          ;=====T1溢出中斷(計時程序)=====
          T1INT: MOV TH1,#3CH
          MOV TL1,#0B0H
          INC R0
          RETI
          END

          蜂鳴器相關(guān)文章:蜂鳴器原理

          上一頁 1 2 3 下一頁

          關(guān)鍵詞: 單片機(jī) 搶答器 8051

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();