Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
31 views

Connecting and Using A Text LCD Display: Problem

This document provides instructions for connecting and using a text LCD display with an Arduino. It discusses using the LiquidCrystal library to drive LCD displays based on the HD44780 controller chip. It shows the common LCD pin connections and provides an example code to print text to the LCD at a specific position and continuously update the value. It also discusses formatting text on the LCD by controlling the cursor position, such as to display countdown values from 9 to 0 on separate rows.

Uploaded by

Jun Hast
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Connecting and Using A Text LCD Display: Problem

This document provides instructions for connecting and using a text LCD display with an Arduino. It discusses using the LiquidCrystal library to drive LCD displays based on the HD44780 controller chip. It shows the common LCD pin connections and provides an example code to print text to the LCD at a specific position and continuously update the value. It also discusses formatting text on the LCD by controlling the cursor position, such as to display countdown values from 9 to 0 on separate rows.

Uploaded by

Jun Hast
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Connecting and Using a Text LCD Display

Problem
You have a text LCD based on the industry-standard HD44780 or a compatible
controller chip, and you want to display text and numeric values.

Solution
The Arduino software includes the LiquidCrystal library for driving LCD displays
based on the HD44780 chip.

Figure below shows the most common LCD connections. It’s important to check
the data sheet for your LCD to verify the pin connections. Table below shows the
most common pin connections, but if your LCD uses different pins, make sure it
is compatible with the Hitachi HD44780—this project will only work on LCD
displays that are compatible with that chip. The LCD will have 16 pins (or 14 pins
if there is no backlight)—make sure you identify pin 1 on your panel; it may be
in a different position than shown in the figure.

Connections for a text LCD


// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello Students");
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}

Formatting Text
Problem
You want to control the position of text displayed on the LCD screen; for example,
to display values in specific positions.

Solution
This sketch displays a countdown from 9 to 0. It then repeat the sequence and
display on the LCD:

/*
LiquidCrystal Library - FormatText
*/
#include <LiquidCrystal.h> // include the library code:
//constants for the number of rows and columns in the LCD
const int numRows = 2;
const int numCols = 16;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
// set up the LCD's number of columns and rows:

lcd.begin(16, 2);
}
void loop()
{
lcd.begin(numCols, numRows);
lcd.print("Starting count"); // this string is 12 characters long
for(int i=9; i >= 0; i--) // count down from 9
{
// the top line is row 0
lcd.setCursor(15,0); // move the cursor to the end of the string printed above
lcd.print(i);
delay(1000);
}
}

You might also like