Component Documentation: Original JHD 20x4 character LCD Display with Blue Backlight
The Original JHD 20x4 character LCD Display with Blue Backlight is a popular and widely-used liquid crystal display module suitable for various IoT applications. This display features a 20x4 character format, meaning it can display up to 20 characters per line and has 4 lines in total. The display also comes with a blue backlight, making it suitable for use in low-light environments.
The display module has a standard 16-pin interface, with the following pinout:
| Pin | Function |
| --- | --- |
| 1 | VSS (Ground) |
| 2 | VCC (Power Supply) |
| 3 | VE (Contrast Adjustment) |
| 4 | RS (Register Select) |
| 5 | R/W (Read/Write) |
| 6 | EN (Enable) |
| 7 | D0 (Data Bit 0) |
| 8 | D1 (Data Bit 1) |
| 9 | D2 (Data Bit 2) |
| 10 | D3 (Data Bit 3) |
| 11 | D4 (Data Bit 4) |
| 12 | D5 (Data Bit 5) |
| 13 | D6 (Data Bit 6) |
| 14 | D7 (Data Bit 7) |
| 15, 16 | Backlight Anode and Cathode |
### Example 1: Basic LCD Display using Arduino
```c++
#include <LiquidCrystal.h>
#define LCD_RS 12
#define LCD_EN 11
#define LCD_D4 5
#define LCD_D5 4
#define LCD_D6 3
#define LCD_D7 2
LiquidCrystal_I2C lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
void setup() {
lcd.begin(20, 4); // Initialize LCD with 20x4 characters
lcd.setCursor(0, 0); // Set cursor to first row, first column
lcd.print("Hello, World!");
}
void loop() {
// Do nothing, just display the message
}
```
In this example, we connect the LCD display to an Arduino board, and use the `LiquidCrystal_I2C` library to interact with the display. We initialize the display with a 20x4 character format, set the cursor to the first row and first column, and display the message "Hello, World!".
### Example 2: LCD Display with Raspberry Pi using Python
```python
import RPi.GPIO as GPIO
import time
LCD_RS = 17
LCD_EN = 23
LCD_D4 = 24
LCD_D5 = 25
LCD_D6 = 8
LCD_D7 = 7
GPIO.setup(LCD_RS, GPIO.OUT)
GPIO.setup(LCD_EN, GPIO.OUT)
GPIO.setup(LCD_D4, GPIO.OUT)
GPIO.setup(LCD_D5, GPIO.OUT)
GPIO.setup(LCD_D6, GPIO.OUT)
GPIO.setup(LCD_D7, GPIO.OUT)
def lcd_init():
GPIO.output(LCD_RS, 0) # Reset LCD
GPIO.output(LCD_EN, 1)
time.sleep(0.01)
GPIO.output(LCD_EN, 0)
time.sleep(0.01)
GPIO.output(LCD_RS, 1) # Set LCD to command mode
def lcd_send_command(cmd):
GPIO.output(LCD_D4, (cmd >> 4) & 1)
GPIO.output(LCD_D5, (cmd >> 5) & 1)
GPIO.output(LCD_D6, (cmd >> 6) & 1)
GPIO.output(LCD_D7, (cmd >> 7) & 1)
GPIO.output(LCD_EN, 1)
time.sleep(0.01)
GPIO.output(LCD_EN, 0)
time.sleep(0.01)
def lcd_send_data(data):
GPIO.output(LCD_D4, (data >> 0) & 1)
GPIO.output(LCD_D5, (data >> 1) & 1)
GPIO.output(LCD_D6, (data >> 2) & 1)
GPIO.output(LCD_D7, (data >> 3) & 1)
GPIO.output(LCD_EN, 1)
time.sleep(0.01)
GPIO.output(LCD_EN, 0)
time.sleep(0.01)
lcd_init()
lcd_send_command(0x28) # Set LCD to 20x4 mode
lcd_send_command(0x0C) # Turn on display, cursor off
lcd_send_command(0x01) # Clear display
lcd_send_data(ord('H'))
lcd_send_data(ord('e'))
lcd_send_data(ord('l'))
lcd_send_data(ord('l'))
lcd_send_data(ord('o'))
lcd_send_data(ord(','))
while True:
# Do nothing, just display the message
pass
```
In this example, we connect the LCD display to a Raspberry Pi using the RPi.GPIO library. We define functions to initialize the LCD, send commands, and send data to the display. We then use these functions to set the LCD to a 20x4 mode, turn on the display, and display the message "Hello,".
Note: These examples are just a starting point, and you may need to modify them to fit your specific use case. Additionally, make sure to adjust the pin connections and initialization routines according to your specific setup.