Keyboard + LCD Interfacing with ATMEGA16

It has been two months and more since we planned to interface a Computer Keyboard, a Mobile Phone LCD and a memory card together to make a sort of a minimal standalone computer system.
The process has been long, with major and minor problems keeping on cropping up,stalling work and almost making us give up more than once.

However, today we crossed one more milestone…We have now interfaced the Keyboard and a 16*2 Character LCD simultaneously. That means we have now achieved 60% of what we set out to do.

I have already put up blog posts on Keyboard Interfacing and LCD Interfacing seperately, but making them together proved to be more of a battle than we expected. It wasn’t as easy as just meshing together code from both the examples and making it run. There were a lot of small hardware issues and configurations which kept on coming up, but the most annoying problem was that if the connectors to the LCD aren’t perfect, it would firmly refuse to even start up or start throwing curses in Chinese !!

Also, Keyboard Interfacing was only the beginning, as we had only obtained raw data from the keyboard and that needed to be mapped with its corresponding key. Here’s a rough idea of what all needed to be done :

1. Obtain the raw data from the keyboard and decipher the key which was actually pressed. This was done by including two arrays, one for printing out Upper Case and the other for Lower Case characters.

2. The delay between keypresses needed to be set up properly to avoid a single keypress being detected as multiple key presses.

3. Pressing of Caps Lock and special characters etc needed to be dealt with separately to avoid erroneous/unwanted output and to implement changing of case, backspace,newline etc.

Ok, this could go on, but here’s what this code can do in short :

1. Print key-presses on the LCD (obviously).
2. Detection of Caps-Lock and printing of Upper case and Lower case characters accordingly.
3. Newline feed on pressing Return
4. Erasing of characters on pressing backspace.
5. Clearing of screen on pressing F5

Special characters can be included as well with minor additions, but I’ll leave that for later 😉

Here’s an introductory video :


Here’s the code.Click here to download.

Acknowledgements : Aniket Taati has been in this all along. I don’t know what I would have done without him testing out the code I wrote initially 😉 He’s also responsible for adding a lot of the fancy features that make this project really useful. Many thanks to Rohit Pawar and Rajesh for setting up the hardware 😀