Liquid Crystal Display with Keypad for Arduino Part 2

In many ways using the display to show characters is easier than using the buttons. This is due to the fact that most of the hard work is done by a library.

One point worth noting is that a while ago there were problems with the design of these LCD boards that could potentially damage your Arduino. The problem occurs when you try to dim the display using pin D10, there is a post on the Arduino Forum well worth a visit if you were thinking of dimming the display. The link for the Arduino Forum is here.

Power Requirements

The LCD and Keypad Shield requires a good 5V power supply to ensure the backlight fully illuminates and the display contrast is high, and if you power your Arduino from USB with the LCD Shield attached you may experience a voltage drop over the USB cable. If you have trouble with display contrast or backlight brightness, try attaching a power supply of around 7 to 9Vdc to the 2.1mm DC jack on the Arduino. A typical symptom in an undervoltage situation is that one line of the LCD will show pale rectangles in place of the characters, and the other line will show nothing at all. The Arduino may even continue running normally because it’s quite happy at just 4V or so, but the LCD and Keypad Shield won’t function.

The board normally has a small variable resistor (often blue) that controls the contrast, if your display does not show correctly then use a small screwdriver to adjust this until the display is correct.

Library Requirements

All the hard work of interfacing with the LCD Shield is handled by the library. The LiquidCrystal library is a core library for Arduino – there should be no need to install it. If you need to install it for some reason, visit the Arduino site.

The following sketch illustrates a simple way to used the display. In the line 


lcd.setCursor(n,m)


//n is the digit, from 0 to 15 and m is the line, from 0 to 1.


/* This is a simple example of how to use the Arduino LCD shield. The shield will work with the standard Arduino LiquidCrystal library.

This code also demonstrates the correct pinnout for the LCD. When you run this program you should see "HELLO WORLD!" appear on the first line of the Display*/


// Include the standard LiquidCrystal library

#include <LquidCrystal.h>


// DIO pin definitions
#define LCD_DATA4 4 // LCD data DIO pin 4
#define LCD_DATA5 5 // LCD data DIO pin 5
#define LCD_DATA6 6 // LCD data DIO pin 6
#define LCD_DATA7 7 // LCD data DIO pin 7
#define LCD_RESET 8 // LCD Reset DIO pin
#define LCD_ENABLE 9 // LCD Enable DIO pin
#define LCD_BACKLIGHT 10 // LCD backlight DIO pin
// Initialise the LiquidCrystal library with the correct DIO pins
LiquidCrystal lcd(LCD_RESET, LCD_ENABLE, LCD_DATA4, LCD_DATA5, LCD_DATA6, LCD_DATA7);


void setup()
{
// Set the correct display size (16 character, 2 line display)
lcd.begin(16, 2);
}


void loop()
{
// Put the LCD cursor on the first row an print the HELLO WORLD message
lcd.setCursor(0,0);
lcd.print("HELLO WORLD !");
}

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