1. Introduction to the LCD2004A Module
2. Connecting the LCD2004A Module to the Arduino Development Board
1. Pin Descriptions
GND —— Ground
VCC —— Power 5V
SDA —— I2C Data Line
SCL —— I2C Clock Line
2. Wiring Instructions
LCD2004A——UNO
VCC————5v
GND———–GND
SDA————SDA
SCL————-SCL
3. Wiring Diagram for the LCD2004A Module and Arduino Development Board
4. Testing the LCD2004A Module with the Arduino Development Board
Testing Steps: After connecting according to the above wiring steps, open the Arduino program, and you will see the following:
After compiling, the display result of the LCD2004A module is as follows:
5. Testing Code
//DFRobot.com
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
uint8_t note[8] = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
uint8_t duck[8] = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x3F for a 20 chars and 4 line display
void setup()
{
// Serial.begin(57600);
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.createChar(0, bell);
lcd.createChar(1, note);
lcd.createChar(2, clock);
lcd.createChar(3, heart);
lcd.createChar(4, duck);
lcd.createChar(5, check);
lcd.createChar(6, cross);
lcd.createChar(7, retarrow);
lcd.home();
lcd.setCursor(0, 0);
for(int i = 0;i < 20; i++) lcd.printByte(6);
lcd.setCursor(0, 1);
lcd.print(” www.eeskill.com “);
lcd.setCursor(0, 2);
lcd.print(” cepark.taobao.com “);
lcd.setCursor(0, 3);
for(int i = 0;i < 20; i++) lcd.printByte(6);
}
void loop()
{
}
6. Precautions
1. The VCC pin of the LED2004A must be connected to 5V; it will not display clearly if connected to 3.3V.
2. If you encounter “library not found” after loading the Arduino program, download it and follow the steps to add it to your working files via “Project -> Include Library -> Add Zip Library”.
3. If the error persists after adding, place the downloaded library files directly in C:\Program Files\Arduino\libraries.
4. If you encounter compilation errors like “Arduino:1.6.5 (Windows XP), Board: ‘Arduino/Genuino Uno’ collect2.exe: error: ld returned 5 exit status”, switch to Arduino version 1.0.
5. Is the LCD2004A module one module or two modules?
Answer: This module is a combination of the LCD2004 screen and the I2C module, which can be purchased pre-soldered or separately, but requires some manual skills.
6. Cannot display properly?
When powered on, it always shows squares as shown:
This situation is generally due to an incorrect address; use the “ScanIICAddress” code to display the device address on the port. As shown below:
After finding it, modify the code to LiquidCrystal_I2C lcd(0x3F,20,4);.