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!