The LCD 16x2 is a widely used liquid crystal display module capable of displaying 16 characters per line across its 2 rows, providing a simple way to showcase data in a human-readable form. This Wokwi Compatible version is specifically designed to interface smoothly with the Wokwi simulator, making it an excellent choice for prototyping and educational purposes. Common applications include user interfaces, status message displays, and simple menus for embedded projects.
Pin Number | Symbol | Function |
---|---|---|
1 | VSS | Ground |
2 | VDD | Power supply (4.7V to 5.3V) |
3 | VO | Contrast adjustment |
4 | RS | Register Select (0: Command, 1: Data) |
5 | R/W | Read/Write (0: Write, 1: Read) |
6 | E | Enable signal |
7-14 | D0-D7 | Data bus lines |
15 | A | Anode for backlight (positive) |
16 | K | Cathode for backlight (negative) |
To use the LCD 16x2 in a circuit:
#include <LiquidCrystal.h>
// Initialize the library with the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// Set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello, World!");
}
void loop() {
// Set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// Print the number of seconds since reset:
lcd.print(millis() / 1000);
}
Q: Can I use this LCD with a 3.3V system? A: The LCD is designed for 5V logic. Using it with a 3.3V system may require level shifters or a different LCD model.
Q: How do I control the backlight brightness? A: The backlight brightness can be controlled by varying the voltage on pin 15 (A) through a PWM signal or by changing the current-limiting resistor value.
Q: What is the purpose of the VO pin? A: The VO pin is used for contrast adjustment. It is typically connected to the middle pin of a potentiometer, with the other two pins connected to VDD and VSS.
Q: Can I display custom characters? A: Yes, the LCD controller allows you to create custom characters by defining a bitmap and storing it in the LCD's CGRAM (Character Generator RAM).