Declaration
LiquidCrystal(rs, enable, d4, d5, d6, d7) |
RW pin can be tied to ground |
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); |
Create lcd Object; 12 is RS, 2 is D7 |
lcd.begin(16, 2) |
Inital 1602 LCD |
lcd.begin(20, 4) |
Inital 2004 LCD |
Display
lcd.write(data) |
Write a character to the LCD |
lcd.print("hello, world!") |
lcd.print(data, BIN) |
lcd.print(data, DEC) |
lcd.print(data, HEX) |
lcd.display() |
Turns on the LCD display |
lcd.noDisplay() |
Turns off the LCD display |
Cursor
lcd.home() |
Reset the cursor position |
lcd.clear() |
Clear screen, Reset cursor |
lcd.setCursor(9, 1) |
Set cursor to row 2 col 10, 0 is the first |
lcd.cursor() |
Display Cursor |
lcd.noCursor() |
Hide Cursor. |
lcd.blink() |
Blinking Cursor |
lcd.noBlink() |
Turns off the blinking cursor |
Position
lcd.scrollDisplayLeft() |
One space to the left |
lcd.scrollDisplayRight() |
One space to the right |
lcd.autoscroll() |
lcd.noAutoscroll() |
Turns off automatic scrolling |
lcd.leftToRight() |
Set the direction for text (Default) |
lcd.rightToLeft() |
Set the direction for text |
Custom
lcd.createChar(num, data) |
Create a custom character, num (0-7), data is byte array |
Custom
lcd.createChar(num, data) |
Create a custom character |
|
num (0-7), data is byte array |
|
|
Sample Code 1
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup()
{
lcd.begin(16,1);
lcd.print("hello, world!");
}
void loop() {}
|
Custom Characters
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte smiley[8] = {
B00000,
B10001,
B00000,
B00000,
B10001,
B01110,
B00000,
};
void setup() {
lcd.createChar(0, smiley);
lcd.begin(16, 2);
lcd.write(byte(0));
}
void loop() {}
|
Up to eight characters of 5x8 pixels are supported (numbered 0 to 7).
|