按鍵開關消抖程序
源代碼:
本文引用地址:http://butianyuan.cn/article/201611/321250.htmled1
led2
switch1
ORG 0000h
setb switch1
setb led1
setb led2
wait:
jb switch1,wait
call debounce_delay
jb switch1,c1_wait
//switch low even after debouncing period
//switch has been succesfully debounced
clr led1
jnb switch1,$
setb led1
ajmp wait
c1_wait:
//Switch PIN high after debounce period so error in debouncing
cpl led2
ajmp wait
debounce_delay:
mov r7,#245
l1_debounce_delay:
mov r6,#40
djnz r6,$
djnz r7,l1_debounce_delay
ret
END
評論