One of the problems in using a microcontroller is that unlike a PC there is no user interface i. e. No screen or keyboard.
There are many ways to read a keyboard depending on what you need to do for example:
1. Add an individual key to each input port (with pullup resistor).
2. Multiplex many keys to a few inputs (using the tristate microcontroller capability).
3. Interface a PC keyboard (using a serial interface).
4. Use a built in ADC to read a set of resistor coded key inputs.
. . and probably many more methods.
Generating text output is more complex because there are no simple devices to do the job but there are two easy choices either:
- Serial port to PC
Using a PC serial port is fairly easy and only requires a level translator chip e. g. MAX232 then you can output text data to the PC screen. This is useful for debugging and developing a PC based application but no good for stand alone operation. For that you need to use an LCD.
The simplest LCD interface is a 16 by 2 line LCD module usually using the standard HD44780 controller. The controller makes it easy to use the LCD as all the difficult LCD interface is contained within the HD44780. All you need to do is send it the correct data through a parallel interface to display a character.
You can also use the LCD as a debugging tool since the data displayed is retained on the display while power is applied so there is not much processing overhead in using an LCD. Another advantage over the serial display is that you can update it very quickly e. g 1 character in 40 microseconds compared to milliseconds for the serial interface (depending on serial speed selected).
The only real problem with the LCD is that is takes up a lot of pins 11 (if you use the full 8 bit interface) but you can reduce this by using the nibble interface to 7 pins and reduce this further to 6 if you don't need to read from the device (HD44780 has RAM inside).
Another option if you have very few pins is to use a serial LCD and this uses just one pin. Obviously this is slower as it uses a serial protocol and it is also more expensive as the serial LCD will need a serial to parallel controller on board.
For both methods modern compilers fully support the device i. e. RS232 and HD44780 so you don't need to start coding at a very low level (the HD44780 has a complex startup sequence) and you can just plug in your chosen device start using it.
Sign up for Microzine to find out how to combine an LCD and 12Key keypad on a single 8 bit port using no hardware interface chips. MicroZine sign up
P. S. The LCD Keypad project is FREE.
John Main's website http://www.best-microcontroller-projects.com provides microcontroller resources and free projects which are fully documented and include schematics and source code.
Free to distribute if the article is kept complete including the Author Bio.