Wiki
New LiquidCrystal / schematics
Hardware configurations and initialization
Here you can find some of the most common LCD connection configurations. All these configurations have been tested with the library and should work well.
4 bit parallel connection
This is the basic parallel conection to an LCD, using 4 IO for data and 2 to control the LCD.
Board layout
The pin assignement is arbitrary and can be mapped to suit your application. Take care when initialising the LCD and make sure you pass the correct IO assignement to the LiquidCrystal constructor ("variable" initialization).
#include <LCD.h>
#include <LiquidCrystal.h>
LiquidCrystal iLCD ( 12, 11, 5, 4, 3, 2 );
void setup ( )
{
iLCD.begin ( 16, 2 );
// your code here...
}
void loop ()
{
// your code here ...
}
I2C connection
The I2C supported by this library is based on the PCF8575 ASIC and has been tested with the schematic below. The library has proven to work with this pin assignement but it can be changed during class construction. Get one pre-assembled from here: electroFUN
Other ASICs are not supported, but it should be straight forward to do so.
Board layout
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x38
LiquidCrystal_I2C iLCD(I2C_ADDR);
void setup ( )
{
iLCD.begin ( 16, 2 );
// your code here...
}
void loop ()
{
// your code here ...
}
Configurable I2C address modules
//this is for a unlabeled i2c LCD interface board which allows for changing its address
// addr, en,rw,rs,d4,d5,d6,d7
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7); // Set the LCD I2C address
// The address pins A0-A2 are pulled high with the three 10k resistors at the bottom of the picture.
// If the three pads A0-A2 are jumpered, the address is changed to 0x20.
ShiftRegister connection
The library has been tested with varios configurations and shiftregisters. Please see schematics below for information.
Other ASICs are not supported, but it should be straight forward to do so.
Non Latching Shift Register
Schematics from the original project home: Shift Register project home
Two wire non latching Shift Register Schematic.
#include <LCD.h>
#include <LiquidCrystal_SR.h>
// constructor prototype parameter:
// LiquidCrystal_SR lcd(DataPin, ClockPin);
LiquidCrystal_SR lcd(2, 3);
void setup ( )
{
lcd.begin ( 16, 2 );
// your code here...
}
void loop ()
{
// your code here ...
}
Three wire non latching Shift Register Schematic.
#include <LCD.h>
#include <LiquidCrystal_SR.h>
// constructor prototype parameter:
// LiquidCrystal_SR lcd(DataPin, ClockPin, EnablePin);
LiquidCrystal_SR lcd(2, 3, 4);
void setup ( )
{
lcd.begin ( 16, 2 );
// your code here...
}
void loop ()
{
// your code here ...
}
Latch Shift Register
Two wire latch Shift Register Schematic. Get one pre-assembled from here: electroFUN
#include <LCD.h>
#include <LiquidCrystal_SR.h>
// constructor prototype parameter:
// LiquidCrystal_SR lcd(DataPin, ClockPin);
LiquidCrystal_SR lcd(2, 3);
void setup ( )
{
lcd.begin ( 16, 2 );
// your code here...
}
void loop ()
{
// your code here ...
}
Three wire latch Shift Register Schematic.
#include <LCD.h>
#include <LiquidCrystal_SR.h>
// constructor prototype parameter:
// LiquidCrystal_SR lcd(DataPin, ClockPin, EnablePin);
LiquidCrystal_SR lcd(2, 3, 4);
void setup ( )
{
lcd.begin ( 16, 2 );
// your code here...
}
void loop ()
{
// your code here ...
}
Other configurations
Here is how to initialize the driver for other boards.
DFRobot
Courtesy of PeterSek
//this is for dfrobot i2c LCD board
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
Pin configuration
DFRobot I2C address 0x27 RS P0 RW P1 E P2 D4 P4 D5 P5 D6 P6 D7 - P7 Backlight - P3 Bl Polarity POSITIVE
mjkdz
Courtesy of PeterSek
//this is for mjkdz i2c LCD board
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // Set the LCD I2C address
Pin configuration
Mjkdz I2C address 0x20 RS P6 RW P5 E P4 D4 P0 D5 P1 D6 P2 D7 P3 Backlight P7 Bl Polarity NEGATIVE
Updated