Help Needed: LCD Lights Up but No Text Displayed

Hi everyone,

I’m working on a project where the LCD lights up, but it’s not displaying any text. I’ve included the code and circuit setup below.

Code:

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

#define SENSOR1_PIN 2
#define SENSOR2_PIN 3

LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust the address if needed
int peopleCount = 0;

void setup() {
  lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
  lcd.backlight();
  pinMode(SENSOR1_PIN, INPUT);
  pinMode(SENSOR2_PIN, INPUT);
  lcd.setCursor(0, 0);
  lcd.print("People Count:");
  lcd.setCursor(0, 1);
  lcd.print(peopleCount);
}

void loop() {
  int sensor1State = digitalRead(SENSOR1_PIN);
  int sensor2State = digitalRead(SENSOR2_PIN);
  
  if (sensor1State == HIGH && sensor2State == LOW) {
    // Someone entering
    peopleCount++;
    updateLCD();
    delay(500); // Debounce delay
  } else if (sensor1State == LOW && sensor2State == HIGH) {
    // Someone exiting
    peopleCount--;
    updateLCD();
    delay(500); // Debounce delay
  }
}

void updateLCD() {
  lcd.setCursor(0, 1);
  lcd.print("                "); // Clear previous value
  lcd.setCursor(0, 1);
  lcd.print("Count: "); // Custom text
  lcd.print(peopleCount);
}

Circuit:

I would really appreciate any insights or suggestions on why the text isn’t appearing. Thank you so much for your help!

Have you adjusted the contrast pot on the LCD?

2 Likes

This didn't work for me.
lcd.begin(16, 2);
Mine worked with this
lcd.init();

Edit: In addition to the contrast suggested by van_der_decken

1 Like

Your picture is not very clear, an annotated schematic would be much easier to follow. I will take a SWAG (scientific wild assumed guess) and say it is doing as expected Pull-up resistors are essential on the I2C bus to ensure proper communication because I2C uses an open-drain (or open-collector) configuration. Without links to the technical information on the hardware I will assume they are probably missing. If they are there they are probably 10K which would be borderline at best to drive the cabling you show.

1 Like

Hi, @alexc1

Have you tried the example codes that come with the Library?

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

Text displayed after adjusting the contrast pot. Thank you!

1 Like