Pages: [1] 2   Go Down
Author Topic: [SOLVED] "LCM1602 IIC A0 A1 A2" (+OTHERS) I2C Controller working with 20x4 LCD  (Read 17447 times)
0 Members and 1 Guest are viewing this topic.
Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

UPDATE: This page on the http://ArduinoInfo.Info WIKI has library information and example code for 3 versions of I2C Backboards:
http://arduino-info.wikispaces.com/LCD-Blue-I2C

This covers display adapter backboards marked:
"YwRobot Arduino LCM1602 IIC V1"
"Arduino-IIC-LCD GY-LCD-V1"
"LCM1602 IIC A0 A1 A2"

That last one was new to me. It's Yet Another variation on the little I2C backpack boards for 16x2 and 20x4 LCD displays.

This one has address 0x20  (The A0, A1, A2 pins are grounded by solder bridges). Here's a Photo:


BUT the internal wiring from the PCF8574T is different and must be handled in Setup.  

Software/Library setup was nicely written up by Gordon Shumway in another post, so I'll steal it here:

Step 1:  Remove all LCD libraries from your Arduino IDE.  Check both the user specific ones, as well as in the Arduino install folder.  Zip them up and save them somewhere else if you think you might need them again, otherwise, delete.

Step 2:  Install the new and improved LCD library by F Malpartida from here:  https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home  This person has done some awesome work for the Arduino community.

And here's the code that works, with the connections fixed in the #defines for the I2C chip to Display connections. Phew!

Code:
/* YourDuino.com Example Software Sketch
 20 character 4 line I2C Display
 ANOTHER NEW TYPE Marked "LCM1602 IIC  A0 A1 A2"
 A0-A1-A2 are grounded so I2C Address is 0x20  
 terry@yourduino.com */
/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library
//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move original LiquidCrystal library elsewhere, copy this in it's place

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574T
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

#define  LED_OFF  1
#define  LED_ON  0

/*-----( Declare objects )-----*/  
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  lcd.begin (20,4);  // initialize the lcd
// Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(LED_ON);
}// END Setup

void loop()   /*----( LOOP: RUNS OVER AND OVER AGAIN )----*/
{

// Reset the display  
  lcd.clear();
  delay(1000);
  lcd.home();
  
// Print our characters on the LCD
  lcd.backlight();  //Backlight ON if under program control
  lcd.setCursor(3,0); //Start at character 3 on line 0
  lcd.print("Hello, world!");
  delay(1000);
  lcd.setCursor(2,1);
  lcd.print("From YourDuino");
  delay(1000);  
  lcd.setCursor(0,2);
  lcd.print("20 by 4 Line Display");
  lcd.setCursor(0,3);
  delay(2000);  
  lcd.print("http://YourDuino.com");
  delay(8000);
} // END Loop

Thanks to  F Malpartida for saving us all a LOT of work, and to Nick Gammon for his I2C scanner!
« Last Edit: April 04, 2013, 06:42:07 am by terryking228 » Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2636
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Terry,
Where is that example/sample code from?
(I'd really like to get it updated)

While setBacklight() works for this device, I would discourage it's use to turn on/off the backlight
as it is used to set an intensity not just for on/off control.
On devices such as this that do not support backlight
dimming, any non zero value will turn the backlight full on, but on devices that support
dimming like when 4bit mode is used, setting the backlight intensity to 1 will be very dim.
If backlight on/off control is desired, then backlight() noBacklight() calls would be the
preferred method as those will work on any device that has backlight control and will
result in full on or full off.

fm's latest library allows setting the backlight bit and polarity in the constructor
as well as turns on the backlight in begin() for all device interfaces.
This can simplify the setup code in the sketch so that it can be the same regardless of the interface
(i2c, SR, 4bit, etc...)
All you have to do is setup the full constructor, then, the begin()
handles everything else regardless of the underlying interface to the LCD.
This allows the actual setup() sketch code to be consistent and the same for all interfaces.
i.e. if you change from i2c to 4bit, all that changes is the constructor.
The sketch code does not have to change.


So for example:
Code:
/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574T
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  3
#define BACKLIGHT_POL POSITIVE // POSITIVE or NEGATIVE depending board design
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

/*-----( Declare objects )-----*/ 
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin, BACKLIGHT_PIN, BACKLIGHT_POL);

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  lcd.begin (20,4);  // initialize the lcd, also turns on backlight
}// END Setup


--- bill
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
I bought 3 of these "LCM1602 IIC" things with the hope I can use the 3 of them in one arduino.
It was a difficult task to get them work until I got to http://arduino-info.wikispaces.com/LCD-Blue-I2C.

The bad news was they ALL have address 0x20 , so I see the same info in the 3 20x4 LCD Displays ( 2004).
Is there a way to change the address to 2 of these 3 circuits?.

thnx
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 65
Posts: 2442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The bad news was they ALL have address 0x20 , so I see the same info in the 3 20x4 LCD Displays ( 2004).
Is there a way to change the address to 2 of these 3 circuits?.
If they are the same as Terry's image in the first post then removing the solder bridge(s) on A0, A1 or A2 so all three LCD's have different combinations should change the address. Remove a bridge and then use a I2C scanner to check the address has changed.
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, is the one that says "LCM1602 IIC A0 A1 A2" I did remove a0 and a2 and gives me de same address, 0x20.
Any Clue?
Logged

Norfolk UK
Offline Offline
Edison Member
*
Karma: 65
Posts: 2442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, is the one that says "LCM1602 IIC A0 A1 A2" I did remove a0 and a2 and gives me de same address, 0x20.
Any Clue?
Strange, can you post a picture of A0-A2 pins you have cleared. It should have worked unless there is also a trace to cut under the solder bridge.
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'll be testing this soon... I plan to update the ArduinoInfo.Info WIKI with photos of the variants.

Two things vary: I2C address (usually 27 or 20) AND pinout of the I2C chip to the LCD pins.  

@bperrybap  My apologies for not seeing you post on the proper changes to the examples! I'll do that and post back here... 
« Last Edit: June 12, 2013, 08:23:37 am by terryking228 » Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Bill, I have redone and tested all the examples using the FM library only. I'm glad to remove that source of confusion for users.

The update page is here:  http://arduino-info.wikispaces.com/LCD-Blue-I2C

I THINK I have the constructor/init right. Please comment!! 
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2636
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool!
The constructors look good.
There is a remaining call to
Code:
lcd.setBacklight(HIGH);  // HIGH or LOW
in the second example. oops....

One thing that might be useful for folks is to show them how to control
the backlight in the examples.

Maybe extend the comment for the begin() calls?
Code:
  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines, turn on backlight

Might be interesting to add this code or something similar
somewhere in setup()  for a quick demo of backlight control?

Code:
/*
* Quick 3 blinks of backlight
*/
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on


As you have seen, some backpacks have a jumper installed on it that can affect backlight control.
Since some jumpers permanently enable the backlight on and some permanently disable the backlight to off,
this small test will allow users  to tell if their backlight circuit is working and figure out how they
want to set their backlight jumper (if they have one).

--- bill


Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2636
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just noticed one other thing. The i2c address in the comment in the last example doesn't match the constructor
Not sure which is correct:
Code:
// 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(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

--- bill
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have taken a picture. Find it atached. This is still giving me 0x20.


* LCM1602.jpg (149.18 KB, 900x348 - viewed 484 times.)
« Last Edit: June 12, 2013, 04:21:20 pm by fedekrum » Logged

Dallas, TX USA
Offline Offline
Faraday Member
**
Karma: 63
Posts: 2636
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

fedekrum,
The photo you supplied appears to show all 3 solder jumpers removed.
Are saying that when you solder across any of the A0, A1, A2 lines the address does not change?
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Bill,
Good on the pointers; I'll update those. (Did first 2)

Thanks! for taking the time to review that. There were 2700 hits on that page already in June and we need it to be.. Right!

« Last Edit: June 12, 2013, 10:28:27 pm by terryking228 » Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Norfolk UK
Offline Offline
Edison Member
*
Karma: 65
Posts: 2442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have taken a picture. Find it atached. This is still giving me 0x20.
A quick look at the datasheet for the PCF8574 say...
Quote
Slave address pins A2, A1 and A0 are held HIGH or
LOW to choose one of eight slave addresses. To conserve power, no internal pull-up
resistors are incorporated on A2, A1 or A0, so they must be externally held HIGH or LOW.
The address pins (A2, A1, A0) can connect to VDD or VSS directly or through resistors.
So the solder bridges sink the address lines to ground by default (to get address 0x20) maybe what you need to do is find out what side of a bridge goes to GND and then solder a wire from the other side of the bridge to VCC to see if that changes the address.
Logged

There is no such thing as a stupid question but there are a lot of inquisitive idiots.

Western New York, USA
Online Online
Faraday Member
**
Karma: 32
Posts: 4245
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
maybe what you need to do ...
There doesn't seem to be any 'maybe' involved here.  According to the material you quoted you must tie each address line either high or low and not leave any of them floating.

Don
Logged

Pages: [1] 2   Go Up
Jump to: