Introduction

This is another great I2C 16x2 LCD display compatible with Gadgeteer modules from DFRobot. With limited pin resources, your project will quicly run out of resources using normal LCDs. With this I2C interface LCD module, you only need 2 lines (I2C)to display the information.If you already have I2C devices in your project, this LCD module actually cost no more resources at all. The adress can be set from 0x20-0x27. Fantastic for Arduino or gadgeteer based projects.

Specification

Contrast Adjust

The contrast can be adjusted by the potential-meter displayed in the following picture.
Toy0046_pinout.jpg

Address Setting

A2 A1 A0 IIC Address
0 0 0 0x20
0 0 1 0x21
0 1 0 0x22
0 1 1 0x23
1 0 0 0x24
1 0 1 0x25
1 1 0 0x26
1 1 1 0x27
NOTE: The default address is 0x20. All the jumper caps will be connected from the factory.

Connection

connection diagram

NOTE: V1.2 has a different power pinout from V1.1, please check the history version for the old connection diagram.

Arduino UNO: connect SDA to pin A4 and SCL to pin A5 on your Arduino. Arduino Leonardo: connect SDA to digital pin 2 and SCL to digital pin 3 on your Arduino.

Library Support Functions

Sample Code

Download Sample code and library

//DFRobot.com
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20,16,2);  // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd

  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
}

void loop()
{
}

Sample sketch: Control the back light of the I2C LCD1602 Module


#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args)  write(args);
#else
#define printByte(args)  print(args,BYTE);
#endif

LiquidCrystal_I2C lcd(0x20,16,2);  // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup(){

  lcd.init();                      // initialize the lcd
  lcd.backlight();

  lcd.home();

  lcd.print("Hello world...");
  lcd.setCursor(0, 1);
  lcd.print("dfrobot.com");

}

int backlightState = LOW;
long previousMillis = 0;
long interval = 1000;

void loop(){

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;

    if (backlightState == LOW)
      backlightState = HIGH;
    else
      backlightState = LOW;

    if(backlightState == HIGH)  lcd.backlight();
    else lcd.noBacklight();
  }
}

If you want to use the library's own sample code, pay attention to modify the initialization statement, need to change:

 LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

to:

 LiquidCrystal_I2C lcd(0x20,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display(All jumpers should be connected\!)

Because the default initialization statement is for LCD1602!

Old version wiki

Projects

DFshopping_car1.png Get I2C/TWI LCD1602 Module from DFRobot Store or DFRobot Distributor.

Category: DFRobot > Sensors & Modules > LCDs, LEDs & Displays > LCD category: Product Manual category: DFR Series category: Modules category: LCDs

category: source category: Diagram category: DFRobot

Turn to the Top