Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
blueroomelectronics said:Hey Gramo, thought you don't like MicroBASIC?
program ps2_test
dim keydata, special, down as byte
main:
CMCON = $07 ' Disable analog comparators (comment this for P18)
INTCON = 0 ' Disable all interrupts
Ps2_Init(PORTA) ' Init PS/2 Keyboard on PORTA
Delay_ms(100) ' Wait for keyboard to finish
do
if Ps2_Key_Read(keydata, special, down) = 1 then
if (down = 1) and (keydata = 16) then ' Backspace
' ...do something with a backspace...
else
if (down = 1) and (keydata = 13) then ' Enter
Usart_Write(13)
else
if (down = 1) and (special = 0) and (keydata <> 1) then
Usart_Write(keydata)
end if
end if
end if
end if
Delay_ms(10) ' debounce
loop until FALSE
end.
Ps2_Init(dim byref port as byte)
Initializes port for work with PS/2 keyboard, with default pin settings. Port pin 0 is Data line, and port pin 1 is Clock line.
You need to call either Ps2_Init or Ps2_Config before using other routines of PS/2 library.