Beginners Robotics Guide : Using LCDs with AVRs

Rating: 3 votes, 5.00 average.
Liquid Crystal Displays ( LCD ) are widely used as output in small systems especially robots . With there ability to display human readable text they are also a great add on to robots and can output great amount of information or be used as a system from which the user can interact . In this simple tutorial you will learn how to interface LCD's , what are the signal required on various pins and C code for using 16x1 and 16x2 LCD's.

LCD : Liquid crystal display ( because its has a crystalline structure and still it flows ) . To learn how it works you can read in scientific book . Now lets come to the point how to interface/connect a intelligent LCD (by intelligent i mean it has a controller built in ) Here is a step by step guide just follow the steps ...

: Identify : Determine what you want LCD are available in many flavors which are specified as follows 16x1 , 16x2 , 20x2 in the format AxB where A is the number of columns ( chatters ) and B is the number of Rows ( lines ) An LCD might also be Back lit .

STEP 2 : Connect : most of the LCD's follow the standard Hitachi Pin out which is simply ...

In some LCD's you might not find the 15 and 16 pin so don't worry .
here is how you must wire them up

Click image for larger version. 

Name:	lcd.gif 
Views:	3330 
Size:	3.9 KB 
ID:	218
STEP 3 : Interface : Now connect pins RS ,RW ,E ,D0 - D7 to pins on the micro controller Lets suppose I connect Data bus on port A and the RS , RW , E on port B . (you can save pins by using LCD in Nibble Mode (4 data pins ) and permanently grounding the RW line ( always in write mode ) . Now well see how to go from simple switching it on to graphics on the LCD .
An Intelligent LCD Need Only a few Commands And data to function
Command Set for the LCD

* : Does Not Matter
DDRAM : Display Data RAM
CGRAM : Character Generator RAM
Address : These are where the characters are meant to be displayed before sending data into the LCD the address can be specified if you want the string to be printed somewhere in the middle after that the address simply increase each time a new character is passed .

A simple 16x1 might be something like this

**All Address are in Hex
***When using an LCD of type 16x1(the on shown above ) specify 2 line display to use it fully ( The Lcd consider the second half as the next line )
Just look up the LCD documentation for the address locations

After You Connect the LCD to the Micro controller And Apply Power The LCD will just show some squares on the screen which might not even cover the whole screen . Adjust the contrast till these squares are barely visible .
For saving Pins on the micro controller i have simply put the RW line connected to the ground (and used a small delay instead of checking the line for the busy flag for the writing )

How to Program in C

* In the 4 bit interface .The lines D0 - D3 are disconnected and the interface is set to 4 line only D4-D7 are connected . When the data is to be written the higher order bits are written first then enable line is pulsed then the lower order bits are written then the line is pulsed
Complete Source Code :

References :
How to use Intelligent LCD's - Julyan Ilett
Library for Hitachi 44780 based 1 or 2 line Text LCD displays - Knut Baardsen


  1. akshay66's Avatar
    No Photos!!!
  2. support's Avatar
    Quote Originally Posted by akshay66
    No Photos!!!
    Fixed, thanks for pointing that out.
  3. alotics's Avatar
    Another beginner's guide, loved it. I guess everything about beginners as of now, interests me a lot. Been looking into robotics since late last year, already got electronics basics. Thanks for this intro guide @support.