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!

Step 1: Parts List

Parts List:
Clear project box (Hammond 1591CTCL - it is a tight fit but works if you place components carefully)
PICAXE 20X2 Microcontroller
16 X 2 LCD - UniQ/eVision GC-1602I1 or equivalent
PS2 Keyboard
6 Pin Female mini-DIN to match keyboard connector (Bulkhead)
5V wall wart - SPS10A-001 or equivalent for 5V power supply (e.g. 9V battery and LM7805 regulator)
(You can also use a battery and clip, e.g. 3 x AAA instead of a wall wart - but do not exceed 5V!!)
A jack which matches the power connector on your wall wart
3.5 mm Stereo Jack - Programming connection
PICAXE USB Programming Cable AXE027
5K Potentiometer
10k resistor
22k resistor
2 x 4.7k resistors
Hook up wire
2" x 6" Breadboard or equivalent,                                                                                                                                                                PCB to fit in box,                                                                                                                                                                              Pushbutton latching on/off switch,                                                                                                                                                                                                          LM7805 (1A) Voltage Regulator,                                                                                                                                                                                              0.01 UF 16V capacitor,                                                                                                                                                                                                   4 - 1/4" standoffs,                                                                                                                                                                                                   8 - 4-40 nuts & bolts,                                                                                                                                                                               9V battery clip and 9V battery.                                                                                                                                                        
<p>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 <u>Switch Case</u> 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. </p><p>Something like this should do.</p><p><strong>SELECT CASE keybd</strong><br><strong> CASE $0d</strong><br> let keybd = &quot; &quot;<br><strong> CASE $1c</strong></p><p> let keybd = &quot; a&quot;</p><p><strong> CASE $32</strong></p><p> let keybd = &quot; b&quot;</p><p><strong> CASE $21</strong></p><p> let keybd = &quot;c &quot;</p><p>.....................................................</p><p><strong> CASE $79</strong></p><p><strong> </strong>let keybd = &quot;+&quot;</p><p><strong> ELSE ; Use this to catch all unused key presses</strong><br> return<br><strong>ENDSELECT</strong> -</p><p>See more at: <a href="http://www.picaxe.com/BASIC-Commands/Program-Flow-Control/select/#sthash.122C8L3E.dpuf" rel="nofollow"> http://www.picaxe.com/BASIC-Commands/Program-Flow...</a></p><p>The 1000 in this is also a timeout debounce so this number could be adjusted to speed up the keyboard reaction time. </p><p>kbin[1000,RetKey],keybd </p>
Hi Skboughton,<br><br>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...<br><br>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.<br><br>Regards<br>Simon
Hi Dylon, <br> <br>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....
Very Nice, but you should do one with avr adruino too!
Very Nice, but you should do one with avr adruino too!
hey, i shop there too ;-)

About This Instructable


73 favorites


More by sncarter: PICAXE Projects PICAXE - Simple Programming Jig A Simple 2 Hour PICAXE Project - Play Tunes with an 08M2 Microcontroller for about $10
Add instructable to: