PIC Microcontroler based Keyboards
Tony Kubek's pickbd2 PC-Keyboard emulator using a PIC16F84
Ken Webster says:
I just happened to have an example [of a keyboard to PIC interface]. It is for a 4x4 keypad connected to a 17C756 on PORTB. It doesn't do the fast scan ... just a plain old one-row-at-a-time scan. I had PORTB (output latch) set to 0. Weak pullups were enabled.Pinout is kinda funky (to make PCB layout easier):
6---(1)-(2)-(3)-(A) | | | | 7---(4)-(5)-(6)-(B) | | | | 5---(7)-(8)-(9)-(C) | | | | 2---(*)-(0)-(#)-(D) | | | | 3 4 0 1 ;------------------------------------------------------------ ;Called by interrupt handler to scan the keypad ;Returns with W=ASCII if a key is pressed, W=0 otherwise ;Interrupt handler performs debounce SCAN1 MOVLW ~0X40 ;Enable ROW0 output MOVWF DDRB NOP NOP BTFSS PORTB,3 RETLW '1' BTFSS PORTB,4 RETLW '2' BTFSS PORTB,0 RETLW '3' BTFSS PORTB,1 RETLW 'A' MOVLW ~0X80 ;ROW1 MOVWF DDRB NOP NOP BTFSS PORTB,3 RETLW '4' BTFSS PORTB,4 RETLW '5' BTFSS PORTB,0 RETLW '6' BTFSS PORTB,1 RETLW 'B' MOVLW ~0X20 ;ROW2 MOVWF DDRB NOP NOP BTFSS PORTB,3 RETLW '7' BTFSS PORTB,4 RETLW '8' BTFSS PORTB,0 RETLW '9' BTFSS PORTB,1 RETLW 'C' MOVLW ~0X04 ;ROW3 MOVWF DDRB NOP NOP BTFSS PORTB,3 RETLW '*' BTFSS PORTB,4 RETLW '0' BTFSS PORTB,0 RETLW '#' BTFSS PORTB,1 RETLW 'D' RETLW 0
See also:
Interested: