Arduino LCD Shield Project: Display ‘Hello World’ Text

LCD Shield is a 16x2 LCD (Liquid Crystal Display) compact module, ready to embed to Arduino header. So, the stackable shield can directly be programmed and used (plug n play) above Arduino Uno board. The boards compatible with the shield are Arduino/Genuino Uno, Mega, Leonardo, and Duemilanove. The LCD module (usually using a Hitachi HD44780) has built in minimum circuit, so you do not need to create your own. Even, it’s already provided several buttons that can be used as a navigation menu on the LCD.


LCD Shield Pinout Configuration

Since it was shaped as a shield, then control pins are also specified by the manufacturer, so we can’t use another pin in Arduino (which are connected LCD pinouts directly) to control it. Arduino pin that's already been reserved for control the shield are:

Pin
Function
8
RS (Register Select)
9
EN (enable)
4
Data-4 (D0 in 4-bit mode)
5
Data-5 (D1 in 4-bit mode)
6
Data-6 (D2 in 4-bit mode)
7
Data-7 (D3 in 4-bit mode)

Thus we MANDATORY use the pins when initializing LCD in our Arduino sketch. You may directly control the LCD shield using command ‘digitalWrite’ in question, but for simplicity's sake, I recommend using an existing LiquidCrystal.h library. You can define this library directly at the top of your sketch because it's a default/built in Arduino library.

Arduino-LCD Shield Sketch Handler

Here is an example to show 'Hello World' on the LCD shield using Arduino script.

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  lcd.begin(16, 2);
  lcd.print("Hello World");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print("ArduinoGeek.com");
}

Note that in line [1], we must define ‘LiquidCrystal’ library,so all functions in this library can be used. Next, in line [2] we need to define the pins used in this LCD shield (see on table above). Next we need to initialize the LCD shield with lcd.begin (16.2); in block setup (see row [4]). And to display 'Hello World' text on LCD shield, you can easily do with function lcd.print (row [5]).

You did it. Easy enough, right? So in essence, working with LCD shield and a normal LCD (with a minimum circuit created your own) are equal either of library usage and how to access control pins. The difference is if works with LCD shield, control pins connection in Arduino pins were already determined and can’t be changed, whereas if you use a non LCD shield you can configure it by yourself. So its concerns are dependent on your system design, if you use LCD shield, everything (dimension, header, pinouts) has been determined and we have to follow, while using the bare LCD we can be more flexible (custom) in designing our own system ( PCB size, PCB layout, enclosure dimension, etc).

In the next tutorial I’ll demonstrated this library usage to create an RPM meter for motors DC / AC.
Previous
Next Post »