Jose Antonio Gracia Negre wrote: > > Hello > I want to connect pic 16f84 to a PC like keyboard. > A long time ago they asked for something similar. > Somebody can send a direction or schemes and program to me to make it. ? > > Anticipated thanks > Jose Antonio Gracia Here is a routine to read a 3 X 4 keypad PortB bits <6:3> = outputs connected to the 4 rows PortB bits <2:0> = inputs connected to the 3 columns with pull DOWN resistors. Set TMR0 for an acceptable delay loop. Row and Col registers can be defined as a single RAM register if you like. keyloop btfss intcon,t0if ; test for TMR0 overfolw goto keyloop bcf intcon,t0if ; clear overflow flag ; ; SCAN KEYBOARD ; movlw 0xFF movwf keyres ; final keypress result movlw b'00001000' movwf row ; bit corresponding to row being scanned ; scnrow movf row,w ; activate keyboard row movwf portb goto wait1 ; small delay wait1 goto wait2 wait2 movf portb,w ; scan column andlw b'00000111' ; mask off row data btfss status,z goto coldcy ; column is active, decypher which ; rlf row ; set for next row movlw .3 addwf keyres ; add for next 3 buttons btfss row,7 ; test for last row to scan goto scnrow ; clrf portb bcf flag1,keysrv ; clear key serviced flag goto keyloop ; coldcy movwf col ; store column result btfsc flag1,keysrv ; has key been serviced already goto keyloop ; yes, ignore keypress ; rolcol incf keyres rrf col ; decypher which column btfss status,carry goto rolcol ; bsf flag1,keysrv ; flag key serviced movf keyres,w ; key function routines addwf pcl goto key1 goto key2 goto key3 goto key4 goto key5 goto key6 goto key7 goto key8 goto key9 goto keystar goto key0 goto keyhatch -- Best regards Tony http://www.picnpoke.com Email sales@picnpoke.com