Arduino Forum

Using Arduino => Displays => Topic started by: bobmixon on Feb 08, 2019, 01:03 am

Title: LiquidCrystal_I2C - How to change pins
Post by: bobmixon on Feb 08, 2019, 01:03 am
Greetings,

Using the LiquidCrystal_I2C library, I use pins A4 and A5 as I read in some documentation. I don't see anywhere I can change the pins I use?

Thank you! ✌️
Title: Re: LiquidCrystal_I2C - How to change pins
Post by: marco_c on Feb 08, 2019, 05:27 am
It might be useful to explain why you need to change these pins, because the correct solution may not be changing pins. A4 and A5 are the hardware I2C pins.
Title: Re: LiquidCrystal_I2C - How to change pins
Post by: Paul__B on Feb 08, 2019, 12:01 pm
Using the LiquidCrystal_I2C library, I use pins A4 and A5 as I read in some documentation. I don't see anywhere I can change the pins I use?
And there is a very good reason for that.

But you pose the archetypal "newbie" "XY Problem (http://xyproblem.info/)".  :smiley-roll:
Title: Re: LiquidCrystal_I2C - How to change pins
Post by: kon1958 on Feb 08, 2019, 04:19 pm
https://www.youtube.com/watch?v=xVC0X_PE_XE&t=288s
Title: Re: LiquidCrystal_I2C - How to change pins
Post by: Geek Emeritus on Feb 08, 2019, 08:03 pm
if you are using an UNO there are separate SDA & SCL pins which do the same thing, but things got twitchy when I used A4 & A5 as digital inputs. so your choice is I2C and 4 Analog pins no I2C and 6 Analog pins.
Title: Re: LiquidCrystal_I2C - How to change pins
Post by: Paul__B on Feb 08, 2019, 10:54 pm
https://www.youtube.com/watch?v=xVC0X_PE_XE&t=288s (https://www.youtube.com/watch?v=xVC0X_PE_XE&t=288s)
That's a bit dated - bperrybap's HD44780 library installed intrinsically from the IDE library manager is substantially enhanced.
Title: Re: LiquidCrystal_I2C - How to change pins
Post by: 3x0c3t on May 14, 2020, 01:20 am
Hello,

It works with the I2C module connected to the LCD screen. But not with all of the Digital Pins obviously...

Instead of LiquidCrystal.h, try this one :


<LiquidCrystal_I2C.h>

with this library
<Wire.h>

And

Wire.begin(D6,D3); // SDA > D6 | SCL > D3  >>>CHANGE FOR YOUR PINS CONFIGURATION.<<<
 IF IT DOESN'T WORK TRY TO SWITCH TO SCL > D6 | SDA > D3... ( I observed differences with NODEMCU V2 & V3...

Like this :

Code: [Select]

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

LiquidCrystal_I2C lcd(0x27,16,2);  // CHANGE the "0x27" ADRESS FOR YOUR SCREEN CONFIGURATION
void setup()
{
  Wire.begin(D6, D3); //  SCL > D3 | SDA > D6  | IF IT DOESN'T WORK TRY TO SWITCH TO SCL > D6 | SDA > D3... ( I observed differences with NODEMCU V2 & V3...
  lcd.init();                      // initialize the lcd
  lcd.clear();

// Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(0, 0);  
  lcd.print("IT WORKS ! :D");
}

void loop()
{
}
Title: LiquidCrystal_I2C - How not to change pins
Post by: Paul__B on May 14, 2020, 03:56 am
I would again refer you - or anyone else - to Bill Perry's "HD44780" library which should be installed specifically using the IDE library manager, not from a 'net source.

This installs a plethora of examples which allow you to either determine the exact configuration of the particular "backpack" or simply to allow his code in the vast majority of cases, to determine it and use it with no prior configuration.