sunrays

Just another WordPress.com site

Connecting the LCD Display to the Arduino.

on April 2, 2012

HARDWARE:

The Arduino has an entire library dedicated to the task of interfacing a LCD Display with the Arduino board. To take advantage of that, the LCD Display has to have a Hitachi HD44780 compatible driver. There are many of them out there, and you can usually spot them by the 16-pin interface. Most common ones have a display of 16×2 or 20×4. I picked a 20×4 for my use.

Hitachi HD44780 20x4 Display

20x4 LCD Display

Any of the many pins of the Arduino can be used to connect to the LCD Display. Further, it can be done using 4 or 8 data lines. In case the LCD is being used with 4 data lines, D0-D3 are usually left unconnected.  The thing to remember is that when the variable LiquidCrystal is created in the code using the function LiquidCrystal(rs, rw, enable, d4, d5, d6, d7), the pins are initialised in the right order.  I used the 4 data line connection and connected the LCD Dsiplay to pins 30-35. The initialization looks like this:

// LCD Display
LiquidCrystal lcd(30, 31, 32, 33, 34, 35); //LiquidCrystal lcd(RS, E, D4, D5, D6, D7), initialize the library with the numbers of the interface pins

This was my first time soldering something like a LCD Display and boy did it hurt my eyes. The only thing I have soldered before is a few hundred solar cells but well, there is room for error there (Shorted a cell? Ok, ok. We have seven spare cells. Let’s use them.) Happy to say, I did a good job with the soldering! Oh well, so the soldering is done, let’s talk about the connections from the Display to the Arduino:

  • LCD RS pin to digital pin 30
  • LCD Enable pin to digital pin 31
  • LCD D4 pin to digital pin 32
  • LCD D5 pin to digital pin 33
  • LCD D6 pin to digital pin 34
  • LCD D7 pin to digital pin 35
  • A pot (but a resistor works just fine) to +5V and GND, with it’s wiper (output) to LCD screen VO pin (pin3).
LCD Connections

LCD Connections

The coding is rather simple and straightforward. The LiquidCrystal library outlines each function with examples.SOFTWARE:

My setup looks like this:

LCD Connection Set Up

LCD Connection Set Up


The final outcome was this:

LCD Display

It Works!

The code I used is here:

#include <LiquidCrystal.h>
// LCD Display
LiquidCrystal lcd(30, 31, 32, 33, 34, 35); //LiquidCrystal lcd(RS, E, D4, D5, D6, D7), initialize the library with the numbers of the interface pins
void setup()
{
lcd.begin(20,4); //20 columns and 4 rows in the lcd display
}
void loop()
{
lcd.setCursor(0, 0); //set the location at which subsequent text written to the LCD will be displayed
lcd.clear();
lcd.print(” It Works! 🙂 “);
delay(5000);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: