Scematic diagram of the circuit
A very simple circuit to experiment with AT90S2313, 2x16 LCD display and 4x4 keypad. The clock based on 4 MHz crystal, but you can use anyone crystal between 1-4 MHz. The keys with the name "A", "B" ... "F" are typed to the LCD with numbers 10-16.
Because the AVR have only 15 I/O pins we are working the LCD display with 4-bit databus. The 4 resistors (10K) are to protect the AVR from the shortcuts as the coloumn of the keypad is change.
I make the source code with a simple form, that its mean I don't make any economy to the memory, to understand the beginner how does the circuit its working.
How this is works
The AVR configure the PortB as PB0-PB3 inputs and PB4-PB7 outputs. At the firt, the AVR put the pin PB4 at logic '0' to enable the column1 (the first 4 keys) and reading the state of the keys. If we have pressed any of the 4 firt keys then the AVR send the number of the key to the LCD display. If we have not pressed any of 4 first keys, theAVR put the PB4 at logic '1' and PB5 at logic '0' to enable the 2th column. Reading the state of the keys and display the resault to LCD, etc, until to read the 16th key. After that, the circuit start again to read from the 1st key (1st column) .
Dowload the schematic, hex and source code lcd_keys.zip