Go Down

Topic: How to modify a program with LDD to fit with I2C LCD (Read 385 times) previous topic - next topic

Ilonard

Hi everyone,

I'm new with Arduino, i'm trying to run a code I got by a member but his code is working with standard LCD. My board is a chinese UNO and works fine. I tested the LCD with test code and it works.

I would like to modify this program in order to run the program with my I2C LCD.

Could you please help me?

see the code in attachement

Thanks

Alan

david_prentice

Find the include and the constructor statements e.g.
Code: [Select]

...
#include <LiquidCrystal.h>  // LCD display library
...
LiquidCrystal lcd(19, 18, 17, 16, 15, 14);      // LCD display (connected to analog inputs / reverse order so I don't have to twist ribbon cable)
...


and replace with I2C versions e.g.
Code: [Select]

...
#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
...
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
...


You can install the hd44780 library via the IDE Library Manager.
Connect LCD to 5V, 0V, SCL, SDA pins on any Arduino.

That is the beauty of the Arduino world.   Many library classes use the same API.
So lcd.print() will work just like Serial.print()
lcd.setCursor() will be the same on most LCD libraries.

David.

bperrybap

Which "I2C LCD" device do you have?
If it is an hd44780 compatible text LCD with an I2C backpack, then what David wrote should work.
If it is another type of hd44780 compatible text LCD device like one with native i2c capabilities then it might still work with the hd44780 library but with a different i/o class .

But if it is a graphical LCD, then it will require a different library and require more changes.

--- bill

Go Up