I need help with 1602 LCD

Do you know what is wrong with my code?

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

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

void loop() {
lcd.print("Hello World");
delay(5000);

lcd.clear();

lcd.setCursor(3, 1);
lcd.print("I am a ROBOT");
delay(5000);

lcd.clear();
delay(5000);
}

At first glance it looks like your code prints out a couple of strings but you haven't told us what's not working, or how you've wired up your LCD. A schematic would help.

Send us crystal balls and we might be able to tell, or post facts according to the first topic telling how to get the best from this Forum.

Does the compiler give any guidance?

Hi, the other replies are correct. please provide more information.
However, with the limited information you give you could try the following:

  1. Commonly, many folk forget to connect the contrast pin on these LCDs. It is usually pin 3 on the LCD. Google on how to connect a 10K potentiometer so you can adjust the contrast. The LCD might be working but the contrast is not set so you cannot actually see the text.
  2. The connections look as per the standard guidance in the library. However, this uses 6 pins. Although you cannot always use I2C, there are I2C (IIC) serial adapters that make it a bit easier for many (i.e. it only needs 2 pins) There is a library for that LiquidCrystal_I2C, but you will also need <wire.h>.
  3. Have you the correct power to the LCD? Are you using 3.3v? The LCD may need 5V

If this fails to help, please post a schematic.
If you need a bezel for the project, check out my web site.

Hello,
Well, if you start to play with an Arduino and the LiquidCrystalDisplay you shall use the exmples provided by the IDE.

It is somewhat dubious as to whether the OP is actually "listening" as (s)he has not responded in some five days.

However one of the first problems encountered is failure to set the contrast control which results in a completely blank display. When set correctly, at least a row of "blocks" on the upper line will show.

Another problem is failure to connect the R/~W line (pin 5) to ground.

Unfortunately, much of what you would find through Google about the contrast control is quite wrong.

A good start is to connect pin 3 - "Vo" to ground. For proper adjustment, "Vo" should connect to ground through a 1k variable resistor. No connection to 5 V - "Vcc". An inappropriate 10k potentiometer can best be used by connecting the wiper to "Vo" and both ends to ground! :grin:

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