AVR 2×16 LCD and 4×4 keypad driver

A very simple circuit to experiment with AT90S2313, 2×16 LCD display and 4×4 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) .

The schematic, hex and source code: lcd&keys.zip


  • 1 x AT90S2313
  • 1 x 2×16 LCD display
  • 4 x 10kOhm resitor
  • 1 x 4Mhz Crystal
  • 2 x 22 pF condensator

Copyright Serasidis Vasilis

Leave a Reply

Your email address will not be published. Required fields are marked *