LiquidCrystal_I2C - How to change pins

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! :v:

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.

bobmixon: 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". :roll_eyes:

https://www.youtube.com/watch?v=xVC0X_PE_XE&t=288s

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.

kon1958: 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.

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 :

with this library

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 :

#include 
#include 

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()
{
}

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.