LCD 16x2 - What am I missing?

Dear All,

I used this tutorial to connect the LCD16x2 . I already had it working.

I wanted to try some other stuff so I connected everything again as descibed in the tutorial. I was not able to succesfully finish the "Hello World" - example, so I thought something was wrong with my display or Arduino. I build the setup again with other components but same story.

When I tried to code below ( to test the characters) it was working! :o

What am I missing to complete the simple "Hello World" - example?

#include <LiquidCrystal.h>

//LiquidCrystal(RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte customChar[8] = {
  0b00110,
  0b01001,
  0b01001,
  0b00110,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

int row = 0;
int col = 0;

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

void loop() {

// column (0-15), row (0-1)
  lcd.setCursor(col, row);
  lcd.write((uint8_t)0);
  delay(100);
  lcd.clear();
    
  if (col < 15) {
    col = col +1;
  }
  else { 
    if (row < 1) {
    row = row +1;
    col = 0;
  }
  else { 
    row = 0;
    col = 0;
  }
  }
 
//  delay(500);
}

“ What am I missing to complete the simple "Hello World" - example?”

We can only you what the problem is if we sit at desk and watch what you are doing. :frowning:

Maybe you have a bad connection in your wiring.

Congratulations on using code tags!

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0

You have posted some code that does work? But you want us to help with some code that does not work, but you did not post that code? How can we do that?

I was not able to succesfully finish the "Hello World" - example

What do you mean by "finish" in this sentence? Does the sketch not compile? Upload? Run?

Thank you for your comments. I understand and please let me explain again. This is how I connected my display:

As writtten above, I have already used the code below before to learn how to use a display and this was working:

/*
 * https://www.circuitbasics.com/how-to-set-up-an-lcd-display-on-an-arduino/
 */

#include <LiquidCrystal.h>

//instellen pin LCD
//LiquidCrystal lcd(RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
// column (0-15), row (0-1)
  lcd.setCursor(0, 1);
  }

void loop() {

  lcd.print("hello, world!");
  delay(500);
  lcd.clear();
  delay(500);
}

When I run this, it seems that row 1, column 2 is only blinking. I have checked wires as advised above but no changes. When I run the following code below, the character is displayed on each position. So my question is why is code 2 working and code 1 (Hello World) not working. Even when I use another Arduino and another LCD. :confused:

#include <LiquidCrystal.h>

//instellen pin LCD
//LiquidCrystal(RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte customChar[8] = {
  0b00110,
  0b01001,
  0b01001,
  0b00110,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

int row = 0;
int col = 0;

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

void loop() {

// column (0-15), row (0-1)
  lcd.setCursor(col, row);
  lcd.write((uint8_t)0);
  delay(200);
  lcd.clear();
    
  if (col < 15) {
    // kolom verder
    col = col +1;
  }
  else { 
    if (row < 1) {
    // rij verder
    row = row +1;
    col = 0;
  }
  else { 
    row = 0;
    col = 0;
  }
  }
 
//  delay(500);
}

Try

/*
 * https://www.circuitbasics.com/how-to-set-up-an-lcd-display-on-an-arduino/
 */

#include <LiquidCrystal.h>

//instellen pin LCD
//LiquidCrystal lcd(RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
// column (0-15), row (0-1)
  }

void loop() {

  lcd.setCursor(0, 1);
  lcd.print("hello, world!");
  delay(500);
  lcd.clear();
  delay(500);
}

Incidental: Get rid of the connection (wire shown red) between the potentiometer and 5 V - it is a stupid design blunder perpetuated over many years. Removing the connection will make contrast setting easier.

Sorry for my late reply but I was abroad.

  1. I have changed the connection. That works fine, thank you.
  2. I have changed the code, nothing happens. Same problem stays.

I have no clue. Anything else I need to try?

LCD's can be pretty slow with custom characters. The customChar in your secons sketch is a small 'o' used to indicate 'degrees' as in degrees Celsius. To accommodate the slow builtup of pixels a delay is introduced in the loop after writing the customChar to screen:.

In the customChar sketch the loop contains

lcd.setCursor(col, row);
lcd.write((uint8_t)0);
delay(100);

increase the delay to 500 and see the result!

@photoncatcher the OP is saying that the sketch that prints the custom character works ok. It's the simpler "hello world" sketch that is not working.

When I run this, it seems that row 1, column 2 is only blinking

Can you explain in more detail what you see? When you say "row 1" do you mean the top row (which is row 0 in the code)?

I rebuilt the construction exactly according to the OP's wiring diagram, with a 16x2 LCD display, and copy-pasted and ran both sketches supplied: my LCD display exactly behaves as it is supposed to do in both sketches (increased delay somewhat in the sketch with the custom character.
Suggestion: replace the breadboard, replace all wiring. There might be a lousy wire or loose contact.