Reputation: 1
I am working on an electronic door lock project using Arduino Uno R3, 16x2 I2C LCD, 4x4 keypad, servo motor, and buzzer. The program asks the user to enter a PIN code to unlock the door. However, when running the program, the LCD does not display any content.
I have used the LiquidCrystal_I2C.h library and declared the LCD as follows:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 16, 2); // I2C address of the LCD
In setup(), I have initialized the LCD:
void setup() {
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the LCD backlight
lcd.setCursor(0, 0);
lcd.print(" Enter PIN: ");
}
But when I run the program, the LCD does not display anything. I have checked the wiring but still cannot find the cause.
What I have tried: Check the wiring between Arduino and LCD. Make sure the LiquidCrystal_I2C.h library is installed. Try changing the I2C address (0x20, 0x27, 0x3F) but still no result. Write a simple program just to print "Hello World" on LCD, but it also does not display anything. Run the code below to scan the I2C address to check the real address of the LCD:
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("Scanning...");
for (byte address = 1; address < 127; address++) {
Wire.beginTransmission(address);
if (Wire.endTransmission() == 0) {
Serial.print("I2C device found at address 0x");
Serial.println(address, HEX);
}
}
}
void loop() {}
The result is that no I2C device is found or the address is different from 0x20.
How can I check if the LCD is working? Is there a way to debug this error? If the I2C address is incorrect, how can I find the correct address?
Upvotes: 0
Views: 20