Liquid Crystal Display (LiquidCrystal Class)

This library allows an Arduino board to control Liquid Crystal Displays (LCDs) based on the Hitachi HD44780 (or a compatible) chip set, which is found on most text-based LCDs. The library works with either 4- or 8-bit mode (i.e. using 4 or 8 data lines in addition to the rs, enable, and optionally, the rw control lines).

To use this library, specify #include <liquidcrystal.h>.

LiquidCrystal Constructor

Description
Generates an object of LiquidCrystal.
Syntax
LiquidCrystal(rs, enable, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d4, d5, d6, d7)
LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)
LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7)
Parameters
rs: The number of the pin that is connected to the RS pin on the LCD
rw: The number of the pin that is connected to the RW pin on the LCD
enable: The number of the pin that is connected to the enable pin on the LCD
d0 to d7: The numbers of the pins that are connected to the corresponding data pins on the LCD.

begin

Description
Specifies the dimensions (width and height) of the display.
Syntax
lcd.begin(int cols, int rows)
Parameters
cols: The number of columns that the display has
rows: The number of rows that the display has
Returns
None

clear

Description
Clears the LCD screen.
Syntax
lcd.clear
Parameters
None
Returns
None

home

Description
Returns the LCD cursor in the home position.
Syntax
lcd.home
Parameters
None
Returns
None

setCursor

Description
Moves the LCD cursor.
Syntax
lcd.setCursor(unsigned char col, unsigned char row)
Parameters
col: The column at which to position the cursor (with 0 being the first column (left edge))
row: The row at which to position the cursor (with 0 being the first row)
Returns
None

write

Description
Writes a character to the LCD.
Syntax
lcd.write(unsigned char data)
Parameters
data: The character code to write to the display
Returns
None

print

Description
Prints character strings or number sequences to the LCD.
Syntax
lcd.print(val)
Parameters
val: Character string or value
Returns
None

cursor

Description
Displays the LCD cursor.
Syntax
lcd.cursor()
Parameters
None
Returns
None

noCursor

Description
Hides the LCD cursor.
Syntax
lcd.noCursor()
Parameters
None
Returns
None

blink

Description
Displays the blinking LCD cursor.
Syntax
lcd.blink()
Parameters
None
Returns
None

noBlink

Description
Turns off the blinking LCD cursor.
Syntax
lcd.noBlink()
Parameters
None
Returns
None

display

Description
Turns on the LCD display, after it has been turned off with noDisplay().
Syntax
lcd.display()
Parameters
None
Returns
None

noDisplay

Description
Turns off the LCD display.
Syntax
lcd.noDisplay()
Parameters
None
Returns
None

scrollDisplayLeft

Description
Scrolls the contents of the display (text and cursor) one space to the left.
Syntax
lcd.scrollDisplayLeft()
Parameters
None
Returns
None

scrollDisplayRight

Description
Scrolls the contents of the display (text and cursor) one space to the right.
Syntax
lcd.scrollDisplayRight()
Parameters
None
Returns
None

autoscroll

Description
Turns on automatic scrolling of the LCD.
Syntax
lcd.autoscroll()
Parameters
None
Returns
None

noAutoscroll

Description
Turns off automatic scrolling of the LCD.
Syntax
lcd.noAutoscroll()
Parameters
None
Returns
None

leftToRight

Description
Set the direction for text written to the LCD to left-to-right, the default.
Syntax
lcd.leftToRight()
Parameters
None
Returns
None

rightToLeft

Description
Set the direction for text written to the LCD to right-to-left (the default is left-to-right).
Syntax
lcd.rightToLeft()
Parameters
None
Returns
None

Sample Program

This sample shows Liquid Crystal Display on GR-ROSE using 3 control lines and 4 data lines.


#include <Arduino.h>
#include <liquidcrystal.h>
 
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
 
void setup()
{
  lcd.begin(16,2); //16x2 lcd initial
  lcd.print("ROSE");
}
 
void loop() {}