Hi to everybody!
I would like to realize a device that converses with a PC through the door PS2, using a PIC 16F877A.

The device should send to the PC, the letter "r" if the key P1 is pressed on RD0, the letter "c" if the key P2 is pressed on RD1 and the letter "s" if the key P3 is pressed on RD2.

I have realized the following code, but it doesn't work... where is the error?

Thanks everybody!
Best regards!

@ DEVICE HS_OSC
@ DEVICE pic16F877A
DEFINE OSC 20
DEFINE SHIFT_PAUSEUS 15

INCLUDE "modedefs.bas"

DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 2
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_LINES 2

symbol P1 = PORTD.2
SYMBOL P2 = PORTD.1
SYMBOL P3 = PORTD.0
symbol LED = PORTA.0
Symbol dat = PORTC.0
symbol clk = PORTC.1

i var byte
Value Var word
clear

ADCON1 = 7
dat = 1
clk = 1

lcdout $fe,1,"** Test PS2 **"
LCDOUT $fe,$c0,"Value: ",Value," "

FOR i = 0 TO 5
TOGGLE LED
PAUSE 200
NEXT i
GOTO Main

Main:
if P1 = 0 THEN
Dato = $73
lcdout $fe,$c0,"Key: ",Value," "
Pause 50
GOSUB TX
endif

if P2 = 0 then
Dato = $63
lcdout $fe,$c0,"Key: ",Value," "
Pause 50
GOSUB TX
endif

if P3 = 0 then
Dato = $72
lcdout $fe,$c0,"Key: ",Value," "
Pause 50
GOSUB TX
endif

goto Main

TX:
shiftout dat,clk,0,[Value\11]
pause 50
return