Go Down

Topic: [SOLVED] Need help with i2c adaptor for 16x2 lcd (Read 458 times) previous topic - next topic

arssant

Hi.

Check my sketch here for the my version of liquidcrystal lib:

http://forum.arduino.cc/index.php?PHPSESSID=4afl8o8hdcsq9tn0a3j2t5pop4&topic=253845.msg1796361#msg1796361

My issue was not the display but serial reading.

Where you wrote :
Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>



#define BACKLIGHT_PIN     13

LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address


I use:

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
float raw;
const int inPin = 0;
int vx;


void setup()
{
  lcd.init();                      // initialize the lcd
  lcd.backlight();
  Serial.begin(9600);
}


Another issues was; get new line from serial reading, check my other posts, i got the solution from another user of the forum.

The lib that you are using is: here

https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

I tried myself that version, but with poor success.

Your I2c adapter is a v3, like mine, we can see A0 A1 A2, that for address setting, like it is: is 0x27 set.


cattledog

#6
Aug 03, 2014, 02:09 am Last Edit: Aug 03, 2014, 04:15 am by cattledog Reason: 1
You may not have the libraries worked out yet, but if indeed you have FMalpartida's library with his <LiquidCrystal_I2C.h> included as part of it, then the constructor is incorrect.

If you run and read the code for the i2cLCDguesser you will see that the constructor is in the format that defines the relevant the pins and backlight

// EN, RW, RS, D4, D5, D6, D7, BL, POL
 { 2,  1,  0,  4,  5,  6,  7,  3, POSITIVE }, // YwRobot/DFRobot/SainSmart
 { 2,  1,  0,  4,  5,  6,  7,  3, NEGATIVE }, // Robot Arduino LCM1602/2004
 { 4,  5,  6,  0,  1,  2,  3,  7, NEGATIVE }, // MJKDZ board
 { 6,  5,  4,  0,  1,  2,  3,  7, NEGATIVE }, // I2CIO board modded for backlight (pnp transistor)
 { 6,  5,  4,  0,  1,  2,  3,  7, POSITIVE }, // I2CIO board modded for backlight (npn transistor)
 { 4,  5,  6,  0,  1,  2,  3,  7, POSITIVE }, // (extra combination of MJKDZ just in case...)

Before this information, you need to supply the I2C address.

Depending on your board, the constructor should look like this.

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 4, 5, 6, 0 ,1 ,2 ,3 , 7,NEGATIVE);


and later in set up

Code: [Select]
lcd.begin(16, 2);

MAS3

That library is also required for the i2cLCDguesser i mentioned earlier.
It helps you find the correct constructor.
Different modules might have different pin to pin connections between the chip and the display, there's no standard.
That even happens between different versions of the same module.
So you'd have to track the traces and draw a map to find out about that, or use the guesser (which one would be easier ?)
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

PaulRB


Did you try bperrybap's i2cLCDguesser sketch yet ?


Thankyou MAS3 !

Bill's guesser sketch got it right on the very first guess. The correct constructor is:
Code: [Select]
lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE)

Go Up