Go Down

Topic: LCD not working (Read 1 time) previous topic - next topic

Jutox

I got this LCD 1602A, so when i put a code in it, all it does is turn the light on and put some black squares on the top of it, i have tried a lot of libraries but none of theme worked, please!! i need some help is for a personal project

Thank you!

Jutox

I got this LCD 1602A, so when i put a code in it, all it does is turn the light on and put some black squares on the top of it, i have tried a lot of libraries but none of theme worked, please!! i need some help is for a personal project

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd (0x27, 16, 2);

void setup(){
  Wire.begin();
  lcd.begin(16, 2);

  lcd.clear();

  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Hello, world!");
  lcd.setCursor(0, 1);
  lcd.print("Tech Krowd");
  //lcd.noBacklight();
}

void loop(){
}

IamFof

Jutox

The display is using an IIC backpack.  Have you tried adjusting the potentiometer?

Fof

Jutox

I moved the potentiometer from the I2C but nothing happens, i mean it just goes black or white but the numbers don't appear

kprims

Try this in your sketch.

Code: [Select]
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); instead of:
LiquidCrystal_I2C lcd (0x27, 16, 2);

bperrybap

Since there is no standard way to wire the pins from the PCF8574 to the hd44780 LCD, the library must "know" the pin mappings. Some libraries (like the one you appear to be using) use hard coded mappings, some libraries let you configure the pin mappings.
If the mappings in the library do not match the way the h/w is wired, then it will not work and you will usually see what is on your display which indicates that the LCD has not been initialized.

You could try my hd44780 library package.
It includes a diagnostic sketch to test the i2c signals and the internal RAM of the LCD.
It will auto detect the i2c address and auto detect the pin mapping between the PCF8574 and the hd44780 lcd.
It is available in the Arduino IDE library manager so you can quickly and easily install it from the IDE GUI.
You can read more about it here: https://github.com/duinoWitchery/hd44780
The i/o class you want for a pcf8574 based backpack is hd44780_I2Cexp and the diagnostic sketch is called I2CexpDiag.

--- bill

floresta

Quote
Try this in your sketch.
Better yet - try looking through this forum for the dozens of recent threads dealing with this type of problem.  Look for threads with I2C as well as LCD in the title (hint, hint).

Don


bperrybap

btw, http://forum.arduino.cc/index.php?topic=454483.0
Is a duplicate of this thread.

I replied over there before I saw this thread.

--- bill

Coding Badly


Threads merged as requested.


Jutox

Try this in your sketch.

Code: [Select]
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); instead of:
LiquidCrystal_I2C lcd (0x27, 16, 2);

it didn't worked

bperrybap

it didn't worked
That isn't clear. As "what" didn't work.
Did it not compile or if it compiled did it not function correctly?
In order to use that alternative constructor, you would also have to change to a different library than you were using in your original example code.


My recommendation was/is in post #5

--- bill

kprims

@bperrybap

"In order to use that alternative constructor, you would also have to change to a different library than you were using in your original example code."


Just for my limited knowledge, I don't understand why he would need another library.

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

I downloaded the sisi.ino from post #1 and commented out:

//LiquidCrystal_I2C lcd (0x27, 16, 2);          And added:

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

The sketch compiles and runs on IDE 1.8.0 with a m128.

Hello world and Tech Krowd on the LCD.

bperrybap

#12
Feb 10, 2017, 08:09 am Last Edit: Feb 10, 2017, 08:10 am by bperrybap
Just for my limited knowledge, I don't understand why he would need another library.
There are multiple i2c backpack libraries that use the same header file LiquidCrystal_I2C.h and they are not the same. They work differently, use different constructors, and are initialized differently.
There is no library that works with both of those constructors so you can't just mix and match constructors and initialization code.

The "LiquidCrystal_I2C" library that is available in the IDE library manager supports the constructor with 3 parameters and does not allow configuring the pin mappings.
It uses lcd.init() vs lcd.begin(cols, rows) to initialize the backpack and lcd.

fm's new liquidcrystal library package includes a "LiquidCrystal_I2C" i/o class that uses a constructor with 10 parameters and allows configuring the pin mappings. It uses lcd.begin(cols, rows) to initialize the backpack and lcd.
fm's library can work with any backpack as long as the pin mappings in the constructor match the pin mappings used by the backpack.

If the 10 parameter constructor and lcd.begin(cols, rows) is working for you, then at some point you must have installed fm's new LiquidCrystal library and the 3 parameter constructor would not work for you.

When messing with these libraries, the best thing is to use the examples that come with the library.
Trying to use examples found through searches may or may not work with the library you have installed.

Even if you get the code to compile for a LiquidCrystal_I2C library that has been installed, there is no guarantee that it will work with the backpack unless the i2c address and the pin mappings used by the library matches the pin mappings used by the backpack.


And all this is why I recommend using my hd44780 library as it will discover the i2c address and auto detect the pin mappings and comes with examples and a diagnostic sketch to help diagnose issues.
It also does not conflict with any installed LCD libraries nor require any manual changes to any existing installed libraries.

--- bill

kprims

"And all this is why I recommend using my hd44780 library as it will discover the i2c address and auto detect the pin mappings and comes with examples and a diagnostic sketch to help diagnose issues.
It also does not conflict with any installed LCD libraries nor require any manual changes to any existing installed libraries."


Thank you Bill for this explanation. This falls into the more I know the less I know category. :-)

Downloaded the hd44780 library and checked out some examples. I2Cexpdiag and HelloWorld work just fine. I am impressed with the info from the I2Cexpdiag. Sure could have used this when first trying to get my LCD's working, when they had different addresses.

Also, thanks for your work on the USBasp's. All of my USBasp's are updated to version 1.06 and work great.

Go Up