This wiki has been archived and made read-only.
For up-to-date information about TkkrLab and it's projects please visit our main website at tkkrlab.nl.

LCM1602 IIC V1

From

Jump to: navigation, search

So wanted to play around with these i2c controlled displays and

figured just connect it install library and be done right?

nope!

Turns out different manufactures use different pin-outs for connecting the i2c

pin-expender to the LCD screen.

so Basically there are three I found each uses a different pin-out,

but no worry there is a library that supports defining that pin-out.

this page describes them and the code to make them operate: (Lcd Tutorial.)

What it looks like

Lcm1602 hello tkkrlab one.JPGLcm1602 hello tkkrlab two.JPGLcm1602 back pcb.JPG Arduino wiring.JPGWhole setup.JPG

How to wire it up

if you look on the back of you controller pcb, you'll see:

GND (power supply groud)

VCC (positive power supply 5v)

SDA (i2c data line)

SCL (i2c clock)

connect GND to a GND pin on the arduino.

the VCC goes to the 5v on the arduino.

SDA and SCL connections may differ depending on the arduino you have (I used a uno)

SDA connected to A4 pin.

and SCL to A5 pin.

the backlight should go on if you haven't loaded any code yet.

Installing the library

  • NOTE: sketchbook is where ever your arduino version saves sketches newer version save it under Arduino instead of sketchbook (iirc)

Before you download the library there is something important that you have to do

that wasn't mentioned on the website I linked before.

and it is that in your arduino folder under libraries you'll find a folder called LiquidCrystal

you have to rename it to for example LiquidCrystal_old

Because the library that is going to be installed is actually a replacement for that library,

and if you install it in your sketchbook under libraries it'll cause all kinds of errors and problems.

so once you renamed that folder go ahead and download the latest version from: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

install the library under libraries under sketchbook, and done!

Example Code

Here is the code I used in the pictures:

/* YourDuino.com Example Software Sketch
 16 character 2 line I2C Display
 Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
 terry@yourduino.com */
 
/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
 
/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    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
 
void setup()
{
  // initialize library
  lcd.begin(16,2);
  // blink backlight three times
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight();
  // set cursor to positon x=0, y=0
  lcd.setCursor(0,0);
  // print Hello!
  lcd.print("Hello!");
  // wait a second.
  delay(1000);
  // set cursor on second line
  lcd.setCursor(0,1);
  // print www.tkkrlab.nl
  lcd.print("www.tkkrlab.nl");
}
 
 
void loop()
{
}