The LCD2004I2C is a 20x4 character LCD (Liquid Crystal Display) module that provides a large display interface for microcontroller projects. It is equipped with an I2C interface, which simplifies the connection to a microcontroller, such as an Arduino, by using just two data lines (SDA and SCL). This display is commonly used in user interfaces, where it can display text and numbers, making it suitable for a wide range of applications including DIY projects, industrial displays, and consumer electronics.
Pin Number | Symbol | Function |
---|---|---|
1 | GND | Ground |
2 | VCC | Supply Voltage (5V) |
3 | SDA | I2C Data Line |
4 | SCL | I2C Clock Line |
5 | RW | Read/Write (typically not used) |
6 | RS | Register Select (typically not used) |
7 | E | Enable (typically not used) |
Note: Pins 5-7 are typically not used when interfacing via I2C as the I2C adapter handles these functions.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD I2C address
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
// Initialize the LCD connected to the I2C module
lcd.init();
// Turn on the backlight
lcd.backlight();
// Print a message to the LCD
lcd.setCursor(0, 0); // Set the cursor to the top-left position
lcd.print("Hello, World!");
}
void loop() {
// Main loop code (if necessary)
}
Note: The I2C address used in the code (0x27) is a common default but may vary for your particular module. Use an I2C scanner sketch to determine the correct address if unsure.
Q: How do I change the I2C address of the display? A: The I2C address is determined by the hardware and usually cannot be changed. If your module supports address changing, it will be done via solder pads or switches on the PCB.
Q: Can I use this display with a 3.3V system? A: The LCD2004I2C is designed for 5V systems. Using it with a 3.3V system may result in dim or no display. Use a level shifter if necessary.
Q: How can I display custom characters? A: The LiquidCrystal_I2C library allows you to create custom characters. Refer to the library documentation for the procedure.
Q: What is the maximum length of the I2C cable I can use? A: The maximum cable length for I2C is generally around 1 meter, but it can vary depending on the bus speed, cable quality, and capacitance. Use shorter cables for more reliable communication.