I have an UNO and I’m trying to connect it to a 1602 display (also a 2004a) via a I2C module, but I’m not having any luck. I believe my soldering is okay, I’ve ran an I2C scanner so my address is correct., and the display powers up and I’m able to adjust the contrast via the I2C module. I have it connect to the 5,0 volt terminals on the UNO and the SDA, SCL to A4 and A5 (I cannot remember which way, but I have tried both). I have not yet tried pull up resistors but I’m still trying to figure out exactly how to do that and what values. The only info on the I2C module is;
“THE PINOUT ON THE BOARD IS AS FOLLOWS:
1 – VSS (ground)
2 – VDD (+5V)
3 – contrast voltage
4 – RS (register select)
5 – R/W (read/write)
6 – Enable
11 – Data 4
12 – Data 5
13 – Data 6
14 – Data 7
15 – LED[+]
16 – LED [-]
Pins 7, 8, 9 and 10 are not connected because not used in 4-bit data mode.”
And the sample code I’m using is;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27); // Set the LCD I2C address
//#define BACKLIGHT_PIN 13
void setup()
{
// Switch on the backlight
// pinMode ( BACKLIGHT_PIN, OUTPUT );
// digitalWrite ( BACKLIGHT_PIN, HIGH );
lcd.begin(16,2); // initialize the lcd
lcd.home (); // go home
lcd.print("Hello");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print ("Canada");
}
void loop()
{
}
I have tried other code, searched and tired other things. I am losing my mind. This is my first project but my first step is to figure out this display, then try connecting to a 2004a.
Any advice will be appreciated.
James
Jarubell:
. . .
I have tried other code, searched and tired other things. I am losing my mind. This is my first project but my first step is to figure out this display, then try connecting to a 2004a.
Any advice will be appreciated.
James
You couldn't have searched very hard if you weren't inundated with threads dealing with I2C LED problems.
Try the stealth search bar at the upper right if the page. Search for I2C LCD.
Have you tried a different library, specifically the one mentioned in most of the recent threads I referred to?
Don
Well jezz, thanks Don, that was helpful.
I have search, but that's usually long after I've finished work and family obligations so yeah, I'm tired.
I have download the library that's been mentioned in multiply threads that you have kindly pointed out. Being new at this and not a long man anymore, it's taking longer to figure out. I will take the only advise you did offer and I'll look into a different library, not sure which one since everyone points to the same one I did download.
This is my first run at Arduino.
James
@OP
1. I always use the following codes while creating the lcd object:
LiquidCrystal_I2C lcd(0x27, 16, 2); and then lcd.init(); under setup(). //I2C addres, 16-characters, 2-line
2. You have used the following instructions:
LiquidCrystal_I2C lcd(0x27); and then lcd.begin(16, 2); under setup().
3. Are the above two equivalent?
4. Your program (listed below) does not compile?
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27); // Set the LCD I2C address
//#define BACKLIGHT_PIN 13
void setup()
{
// Switch on the backlight
// pinMode ( BACKLIGHT_PIN, OUTPUT );
// digitalWrite ( BACKLIGHT_PIN, HIGH );
lcd.begin(16,2); // initialize the lcd
lcd.home (); // go home
lcd.print("Hello");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print ("Canada");
}
void loop()
{
}
5. This is (listed below) the modified version of your program; it now compiles and works in my UNO+LCD setup.
//#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address
//#define BACKLIGHT_PIN 13
void setup()
{
// Switch on the backlight
// pinMode ( BACKLIGHT_PIN, OUTPUT );
// digitalWrite ( BACKLIGHT_PIN, HIGH );
lcd.init();
lcd.backlight();
//lcd.begin(16, 2); // initialize the lcd
lcd.home (); // go home
lcd.print("Hello");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print ("Canada");
}
void loop()
{
}
The problem could be that there are several different LCD to I2C expander pin mappings and the right pin mapping must be specified for the LCD to work.
The library that Don mentioned is the hd44780 library. That library will autodetect the I2C address and, more importantly, the I2C expander to LCD pin mapping. The library is available through the library manager. Go to the library manager and in the Topics drop down select Displays and in the filter box enter "hd44780" . Then select and install the hd44780 by Bill Perry library. Use the hd447680_I2Cexp class.
@GolamMostafa
I'll take a closer look at your response tonight, thank you. The sample code did compile but I had self-inflicted editing issues and had to rewrite the post a few times over ending up writing it in Word so I wouldn't again lose it.
Here it is copied straight from IDE;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27); // Set the LCD I2C address
//#define BACKLIGHT_PIN 13
void setup()
{
// Switch on the backlight
// pinMode ( BACKLIGHT_PIN, OUTPUT );
// digitalWrite ( BACKLIGHT_PIN, HIGH );
lcd.begin(16,2); // initialize the lcd
lcd.home (); // go home
lcd.print("Hello");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print ("Canada");
}
void loop()
{
}
As for the code "LiquidCrystal_I2c" I've seen it written with a series of numbers behind it. I'm going to try the way you have written tonight.
@groundFungus
I do plan on taking Don's advise and I thank you for describing it in more detail. There was another library I downloaded prior to figuring out the one that was mentioned most, but I never did try to use it. LCD03.
Can Libraries conflict with each other even if I just load the one into my project?
Since there are many libraries named LiqutdCrystalI2C and they are slightly different, yes, having more than one installed can cause trouble. Install the hd44780 library and delete the other LCD libraries is my recommendation.
Really, the hd44780 library is the best LCD library available at this time. Not only because of the autodetect feature. Read the Wiki that I linked above. If you have trouble there is a diagnostic sketch that will help to find solutions. The author is frequently on this forum to answer questions, too.
I've seen it written with a series of numbers behind it.
That is the LCD to I2C expander pin mapping. The pin mapping must be correct for the display to work. You can make guesses until it works with those other libraries or let the hd44780 library figure it out for you.
groundFungus - Perfect, thank you