Picture of PICAXE - Interface a PS2 Keyboard with an LCD
This project uses a PICAXE 20X2 microcontroller to interface an old style PS2 keyboard with a 2 X 16 LCD. The program is quite lengthy and is probably not perfect but most functions seem to work. Because some special keys use a preceeding $E0 character which the PICAXE Kbin command ignores, I was not able to decode them. This is my second PICAXE project so there are probably more elegant ways to program these functions, this is just the way that I figured out to do it on my own as very much a beginner.

The PICAXE has been programmed to ignore most keys that don't have much use in this application such as the up and down arrow, ALT, esc, break etc keys for example. CAP lock and Shift work. Shift behaves like CAP lock, press down once and it stays on until you press Shift again. It also displays "CAP" or "SHF" at the top right of line 1 to show that the function is active. The 20X2 has been programmed so that when Line 2 of the LCD display is full, pressing the key for any displayed or right cursor moving character will clear the display and return the cursor to start of Line 2. You will then need to press the key again to get it to display. Also I find that this keyboard to LCD interface is not fast. You need to wait about 1/2 sec after each keypress before it is ready to accept another keypress. I did not persue this because I don't need it to be fast, but suspect that this could be made faster by buffering the incoming characters in multiple variables.

The program is included and you will be able to follow how it works by reading the comments which are quite detailed. They are detailed because I left off working on this program for about a month and was totally lost when I came back to it, so I wanted to make sure that did not happen again. You can easily modify this program to use the keys that are currently ignored. Also, it will be fairly obvious to anyone familiar with PICAXE that this program and hardware can be modified so that instead of displaying characters on an LCD, you could control just about anything - relays, servos, logic, lights etc with a keyboard using this kind technique. I will leave it to the ambitious to do that!
skboughton37 months ago

I loved this project Great Work! I have been thinking about doing something similar so getting a look at your code was a great head start. You mentioned that this took some time to load characters on the LCD. I know if you use a Switch Case it should speed things up a bit. Instead of the code looking at every IF /ELSE/THEN it will jump to the one that is true and then move on. It should speed up substantially with this many possibilities.

Something like this should do.

CASE $0d
let keybd = " "
CASE $1c

let keybd = " a"

CASE $32

let keybd = " b"

CASE $21

let keybd = "c "


CASE $79

let keybd = "+"

ELSE ; Use this to catch all unused key presses

See more at: http://www.picaxe.com/BASIC-Commands/Program-Flow...

The 1000 in this is also a timeout debounce so this number could be adjusted to speed up the keyboard reaction time.


sncarter (author)  skboughton37 months ago
Hi Skboughton,

Thanks for your message. Yes I agree, I've had a bit more experience with PICAXE basic since developing this and I wish I'd used CASE statements! Eventually I will get around to re-writing it when I finish the other projects on the go...

If you are going to do yours soon can you let me know if using CASE statements fixes the speed problem? I'd also be interested to see how you code it in general.

sncarter (author) 2 years ago
Hi Dylon,

Yes, I'm just getting to know Arduino, know PICAXE much better. There are lots of Arduino Temp monitor projects out there already too. One day maybe....
Dylon1242 years ago
Very Nice, but you should do one with avr adruino too!
Dylon1242 years ago
Very Nice, but you should do one with avr adruino too!
panic mode2 years ago
hey, i shop there too ;-)