Go Down

Topic: LiquidCrystal_I2C - How to change pins (Read 1 time) previous topic - next topic

bobmixon

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! ✌️

marco_c

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.
Arduino Libraries https://github.com/MajicDesigns?tab=Repositories
Parola for Arduino https://github.com/MajicDesigns/Parola
Arduino++ blog https://arduinoplusplus.wordpress.com

Paul__B

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".  :smiley-roll:

kon1958

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

Geek Emeritus

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.
All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

Paul__B

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.

3x0c3t

#6
May 14, 2020, 01:20 am Last Edit: May 14, 2020, 01:41 am by 3x0c3t
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()
{
}

Paul__B

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.

Go Up