JahyShow IIC/I2C/TWI 2004 Serial Blue Backlight LCD Module and programming

I'm using advice I found on the internet but not using GitHub codes. Everybodies is different from what I've seen yet they all appear to designate the pins from the screens in the Setup.

Any advice?

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

//14 characters, and 2 lines
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
// put your setup code here, to run once:
/*for set cursor the first number is columns

  • the second number is the rows
  • use lcd.print with input quotations for statements
    */

lcd.begin(20, 4);
lcd.setCursor(1, 0);
lcd.print("LCD Program");

}

void loop() {
// put your main code here, to run repeatedly:

}

The code posted is for a 2-line LCD with I2C backpack (Google it).

A backpack is a port expander, so you need fewer wires to talk to the LCD.
So which LCD do you have. One with many wires, or one with added backpack.
Leo..

When using a display with an I2C backpack, it is common for the declaration of the LCD to include the pin mapping between the I2C interface and the display itself, because different manufactures will wire the connections differently. The libraries that use a simple declaration with only the I2C address and display dimensions are assuming a wiring configuration that is commonly used, and may or many not work with your display.

If you are having trouble with the display, install the HD44780 library in the IDE, and run the File > Examples > HD44780 > ioClass > hd44780_I2Cexp > I2CexpDiag sketch, that will search for any displays connected to the I2C bus, and determine how the I2C expander is wired to the display, displaying that information on the LCD and in the serial monitor.

its a 4 wire mechanism which allows communications about 20 different connectors.

my device allows for a 20 x 4 display.

You seem to be sending commands for both 162 and 204. If you get a standard I2C LCD library and use a 20*4 example, it might work.

You will have the least amount of trouble getting the display to work by using the aforementioned hd44780 library.

I cant get my LCDs to work. Every code Il find doesn't have codes hat function through Arduino.
Can anybody drop an Arduino source for me?

It is similar to LCD 16x2 I2C. You can refer to this LCD I2C tutorial

michael1123:
I cant get my LCDs to work.

The code is only one part of getting an LCD to work. You have to wire it correctly, you have to adjust the contrast correctly and you have to have the right code.

Until and unless you explain all of these details; which display it is , how you have wired it, how you have adjusted it and what code you have used (instructions here, point 7, for posting the code for review), most of us will simply and sensibly ignore your complaints. :roll_eyes:

[Mod edit removed comment]

its an i2c, but i dont want to build a library for it to use it. The 16x2 16pin works fine, but my 4 pin UART lcd wont function.

[Mod edit, removed comment]

Yes it can be problematic locating a working and maintained library for an hd44780 i2c lcd.

UART and I2C are totally different things.
Assuming you are using an hd44780 lcd with one of the common i2c PCF8574 i/o expander based backpacks, use the hd44780 library and the hd44780_I2Cexp i/o class.
It offers a plug an play experience as it locates the i2c address and figures out the pin mapping used on the i2c backpack.

After installing the library, run the included I2CexpDiag sketch to verify that everything is working.
Then you can try the included examples for the hd44780_I2Cexp i/o class and look at them to see which header files to include, how to declare your lcd object and how to use the library.

The library is available in the IDE through the IDE library manager.
You can read more about it on the github repository page and the wiki here:

The library includes lots of documentation / information wich can be found in the Documentation example.

--- bill

+1 for the hd44780 library.

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

To install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

Play nicely guys, the whole world is watching.

Thanks.

Duplicate topics moved to a common section and merged

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.