![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| I am tring to scan 3x4 keypad and I tried many ways but I did not success So I need a sub routin that can scan 3x4 keypad without interrupt I made search on the net but I did not finde what I need Could you Please help me. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| Thank you very much Nigel It's really usefull PIC tutorials and I think I will get what I need :idea: | |
| |
| | (permalink) |
| Code: Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1
ADCON1 = 7 ' PORTA AND PORTE DIGITAL
OPTION_REG.7 = 0 ' PORTB Pullups.
TRISB = %11110000 ' PORTB 0-3 output, 4-7 input
PORTB = 0
TRISC = 0
PORTC = 1
'*******************
keybuf var byte[4]
keycnt var byte
for keycnt = 0 to 4
keybuf[keycnt] = 0
next
'*******************
key var byte
col var byte
row var byte
delay var byte
delay = 0
pause 100
lcdout $fe,1,"4X4-KEYPAD DEMO",$fe,$c0,"2003 - by F.San"
Main:
gosub Chk_KEYPAD
if PORTC = 0 then PORTC = 1
if delay = 100 then PORTC = PORTC << 1
delay = delay + 1
pause 1
goto Main
Chk_KEYPAD:
for col = 0 to 3
PORTB = (dcd col) ^ $f
row = PORTB >> 4
if row != $f then ' key pressed
key = (col * 4) + (ncd (row ^ $f))
gosub DeBounce
gosub Got_KEY
key = 0
endif
next
return
DeBounce:
delay = 0
while (row != $f) and (delay < 20)
pause 10
delay = delay + 1
wend
delay = 0
return
Got_KEY:
'lcdout $fe,1,"4X4-KEYPAD DEMO",$fe,$c0,"BUTTON: ",#key
PORTC = key
'*******************
if keycnt > 3 then
lcdout $fe,1
keycnt = 0
endif
keybuf[keycnt] = key
lcdout #keybuf[keycnt]
keycnt = keycnt + 1
'*******************
return
end if u are interested in basic | |
| |
| | (permalink) |
| 583 words to scan a keypad... :? :shock: | |
| |
| | (permalink) |
| The MAGIC of BASIC ! :lol: Its only 415 without the LCD routines..... | |
| |