[Diao Ye learns programming] Arduino hands-on (127) --- 2004A LCD LCD screen module

The reference to 37 sensors and actuators has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensor and actuator modules on hand, according to the concept of practicing true knowledge (must be done), for the purpose of learning and communication, I am going to try a series of experiments one by one, regardless of success (the program goes through) or not, They will be recorded - small progress or unsolvable problems, hoping to inspire others.

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
Experiment 127: 2004A LCD screen 20X4 J204A character display LCD module 204A LCD/LCM blue screen 5V (with backlight IIC/I2C)

insert image description here
LCD
liquid crystal display (LCD) A type of display used in digital clocks and many portable computers. LCD displays use two sheets of polarized material with a liquid crystal solution between them. Passing an electric current through the liquid rearranges the crystals so that light cannot pass through them. Thus, each crystal acts like a shutter, allowing light to pass through and blocking it. Liquid crystal display (LCD) technology information products are currently developing towards light, thin, short, and small goals, and display products with a long history in computer peripherals are no exception. Under the premise of being easy to carry and transport, traditional display methods such as CRT image tube monitors and LED display panels, etc., are all limited by factors such as excessive volume or huge power consumption, and cannot meet the actual needs of users. The development of liquid crystal display technology is just in line with the current trend of information products. Regardless of the advantages of right-angle display, low power consumption, small size, and zero radiation, users can enjoy the best visual environment.

To trace the origin of liquid crystal displays, we must start with the birth of "liquid crystal". In 1888 AD, an Austrian botanist, Frederick. Friedrich Reinitzer discovered a special substance. He extracted a compound called helical toluate from plants. When doing heating experiments on this compound, he unexpectedly found that this compound has two melting points at different temperatures. And its state is between the liquid and solid substances that we are generally familiar with. It is a bit like a colloidal solution of soapy water, but it has both liquid and crystalline properties within a certain temperature range. Due to its unique State, and later named it "Liquid Crystal", which means liquid crystalline substance. However, although liquid crystals were discovered as early as 1888, it was only 80 years later that they were actually used in everyday products.

In 1968, at the Sanov R&D Center of RCA Corporation (the invention company of radio and television), engineers discovered that liquid crystal molecules would be affected by voltage, change the alignment of their molecules, and deflect incoming light The phenomenon. Using this principle, RCA invented the world's first screen using liquid crystal display. Since then, liquid crystal display technology has been widely used in general electronic products, such as calculators, electronic watches, mobile phone screens, instruments used in hospitals (because of radiation measurement considerations) or screens on digital cameras, etc. Interestingly, the discovery of liquid crystals was earlier than vacuum tubes or cathode ray tubes, but not many people in the world knew about this phenomenon. It was not until 1962 that the first book was written by Joe, a chemist from the RCA research group. Described in the book published by Mr. Joe Castellano. The same as the image tube, although these two technologies were invented by the RCA company in the United States, they were carried forward by Sony and Sharp in Japan respectively.
insert image description here
Physical characteristics of LCD Liquid
crystal is such an organic compound. Under normal temperature conditions, it exhibits both fluidity of liquid and optical anisotropy of crystal, so it is called "liquid crystal". In electric field, magnetic field, temperature, stress, etc. Under the influence of external conditions, its molecules are prone to rearrangement, which changes the various optical properties of liquid crystals. The anisotropy of liquid crystals and their molecular arrangement are easily controlled by external electric fields and magnetic fields. It is this liquid crystal The physical basis of liquid crystal, that is, the "electro-optic effect" of liquid crystal, realizes that light is modulated by electrical signals, thus making liquid crystal display devices. Under the action of different electric currents and electric fields, liquid crystal molecules will be arranged in a regular rotation of 90 degrees to produce light transmittance. In this way, the difference between light and dark is generated under power ON/OFF, and each pixel can be controlled according to this principle to form the desired image.

The physical characteristics of liquid crystals are: when the electricity is turned on, the arrangement becomes orderly, making it easy for light to pass through; when it is not energized, the arrangement is disordered, preventing light from passing through. Let the liquid crystal block or let light pass through like a gate. Technically speaking, the LCD panel consists of two very delicate sodium-free glass materials called Substrates, with a layer of liquid crystal sandwiched between them. When the light beam passes through this layer of liquid crystal, the liquid crystal itself will stand in rows or twist in an irregular shape, thus blocking or allowing the light beam to pass through smoothly. Most liquid crystals are organic compounds consisting of long rod-shaped molecules. In the natural state, the long axes of these rod-like molecules are roughly parallel. Pour the liquid crystal into a well-processed grooved plane, and the liquid crystal molecules will be arranged along the grooves, so if those grooves are very parallel, the molecules are also completely parallel.

insert image description here
The LCD is mainly composed of the following parts
1. Main board: used for input processing of external RGB signals and controlling the work of PANEL.
2.Adapter power adapter: used to convert 90~240V AC voltage into 12V DC power supply for the display to work.
3. Inverter inverter: It is used to convert the 12V DC voltage output by the motherboard or Adapter into the high-frequency 1500~1800V high-voltage AC power required by the PANEL, and is used to light the backlight of the PANEL.
4. PANEL part: This part is a module for liquid crystal display, which is the core component of the liquid crystal display, which includes a liquid crystal panel and a driving circuit.

insert image description here
insert image description here
Working principle
of LCD The composition and working principle of LCD: In terms of the structure of LCD, whether it is a notebook screen or a desktop LCD, the LCD screen used is a layered structure composed of different parts. The liquid crystal display consists of two plates, about 1mm thick, separated by a uniform interval of 5um containing liquid crystal material. Because the liquid crystal material itself does not emit light, there are lamp tubes as light sources under the display screen, and there is a backlight panel (or uniform light panel) and reflective film on the back of the LCD screen. The backlight panel is composed of fluorescent substances. It can emit light, and its main function is to provide a uniform backlight. Light from the backlight enters the liquid crystal layer containing thousands of liquid crystal droplets after passing through the first polarizing filter layer. The droplets in the liquid crystal layer are all contained in tiny cell structures, and one or more cells make up a pixel on the screen. There is a transparent electrode between the glass plate and the liquid crystal material. The electrodes are divided into rows and columns. At the intersection of the rows and columns, the optical rotation state of the liquid crystal is changed by changing the voltage. The role of the liquid crystal material is like a small light valve. .

insert image description here
insert image description here

LCD monochrome principle
LCD technology is to pour liquid crystal between two planes with fine grooves. The slots on these two planes are perpendicular to each other (intersect at 90 degrees). That is, if the molecules on one plane are aligned north-south, the molecules on the other plane are aligned east-west, and the molecules located between the two planes are forced into a 90-degree twisted state. Since the light propagates along the direction of the arrangement of the molecules, the light is also twisted 90 degrees when it passes through the liquid crystal. When a voltage is applied to the liquid crystal, the liquid crystal molecules will rotate to change the light transmittance, thereby realizing multi-gray scale display.

LCD is dependent on polarized filters (sheets) and light itself. Natural light is diffused randomly in all directions. A polarizing filter is actually a series of increasingly thinner parallel lines. These lines form a web that blocks all light rays that are not parallel to these lines. The line of the polarizing filter is exactly perpendicular to the first one, so it can completely block those already polarized rays. Only when the lines of the two filters are perfectly parallel, or if the light itself has been twisted to match the second polarizing filter, does the light pass through.

The LCD is composed of two polarized filters perpendicular to each other, so under normal circumstances it should block all light trying to pass through. However, since the two filters are filled with twisted liquid crystals, after the light passes through the first filter, it will be twisted 90 degrees by the liquid crystal molecules, and finally pass through the second filter.

From the perspective of the structure of the liquid crystal display, whether it is a notebook computer or a desktop system, the LCD display screen used is a layered structure composed of different parts. The LCD is composed of two glass plates with a thickness of 0.7mm, 0.63mm, and 0.5mm (it can also be made thinner by physical or chemical thinning), and a 3~5μm uniform glass containing liquid crystal (LC) material is formed between them. spaced apart. Because the liquid crystal material itself does not emit light, it is necessary to configure an additional light source for the display screen. There is a light guide plate (or uniform light plate) and a reflective film on the back of the liquid crystal display screen. The main function of the light guide plate is to convert the line light source or point light source. is a surface light source perpendicular to the display plane. The light emitted by the backlight enters the liquid crystal layer after passing through the first polarizing filter layer. The crystal droplets in the liquid crystal layer are contained in tiny cell structures, and the liquid crystal material acts like small light valves. Around the liquid crystal material are the control circuit part and the driving circuit part. When the electrodes in the LCD generate an electric field, the liquid crystal molecules will be twisted, so that the light passing through it will be refracted regularly, and then filtered by the second filter layer and displayed on the screen.

insert image description here
2004A LCD character liquid crystal display module

It is a dot-matrix liquid crystal display module specially used to display letters, numbers, symbols, etc. There are 4-bit and 8-bit data transmission modes. Provide 5×7 dot matrix + cursor display mode. Provide display data buffer character generator CGRAM, you can use CGRAM to store font data of 8 5×8 dot matrix graphic characters defined by yourself. Provides a wealth of command settings: clear display; cursor back to origin; display on/off; cursor on/off; display characters flashing; cursor shift; display shift, etc. Provide an internal power-on automatic reset circuit. When the external power supply voltage exceeds +4.5V, it will automatically initialize the module and set the module to the default display working state. The display content is 4 lines, each line displays 20 characters, and the size of each character is 5×8 dot matrix. The character generator RAM can customize characters of 12 different countries such as Chinese, Japanese and Russian according to customer needs.

insert image description here
insert image description here
2004A LCD liquid crystal display module main parameters

Model 2004A

Package COB

Dimensions 98.0mm×60.0mm

Connection method Conductive strip

Field of view size 76.0mm×26.0mm

Interface mode Single row parallel port

Dot size 0.55mm×0.55mm

Backlight type EL/LED

Character size 29.5mm×47.5mm

Display content 20 characters × 4 lines

Working voltage +5V/+3.3V

Display screen yellow green/blue screen/black and white screen

Backlight color yellow green/white light/red light etc.

Working temperature -10~+60℃

Controller SPLC780

Storage temperature -20~+70℃

insert image description here
IIC (Inter-Integrated Circuit) protocol
literally means between integrated circuits, it is actually the abbreviation of I²C Bus, so Chinese should be called integrated circuit bus, it is a serial communication bus, using multi-master-slave architecture, developed by Philips The company was developed in the 1980s for connecting low-speed peripherals to motherboards, embedded systems or mobile phones. The correct pronunciation of I²C is "I-squared-C" ("I-squared-C"), while "I-two-C" is another incorrect but widely used pronunciation. Since October 1, 2006, the use of the I²C protocol has been free of royalties, but manufacturers still need to pay to obtain the I²C slave device address.

I2C, a bus structure. For example: the SPD information in the memory is connected with the BX chipset through the IIC, and the IIC exists in the Intel PIIX4 structure system. With the development of large-scale integrated circuit technology, a single-chip microcomputer made by integrating CPU and peripheral circuits such as ROM, RAM, I/O ports, A/D, and D/A necessary for a single working system into a single chip Or microcontrollers are getting more and more convenient. At present, many companies in the world produce single-chip microcomputers, and there are many varieties. These include CPUs of various word lengths, ROMs and RAMs of various capacities, and I/O interface circuits with different functions, etc. However, the variety and specifications of single-chip microcomputers are still limited, so we can only choose a certain kind of single-chip microcomputer for expansion. There are two ways to expand: one is a parallel bus, and the other is a serial bus. Because the serial bus has few connections and simple structure, it often does not need special motherboards and sockets but directly connects various devices with wires. Therefore, the use of serial lines can greatly simplify the hardware design of the system. PHILIPS company introduced the I2C serial bus as early as more than ten years ago, which can realize functions such as adjudication required by a multi-host system and synchronization of high and low speed devices. Therefore, this is a high-performance serial bus.

Philips Electronics has launched a new type of I2C master selector, which can connect any one of the two I2C master devices to shared resources. It is widely used in computing, communication and network applications from MP3 players to servers, so that Manufacturers and end users benefit from this. The PCA9541 enables two I2C master devices to be connected to the same slave device without being connected to each other, thus simplifying the design complexity. In addition, the new product replaces multiple chips in I2C multi-master applications with a single device, effectively saving system cost.

insert image description here

2004A LCD LCD Module Specifications

1. Name: IIC LCD2004 character liquid crystal display

2. Item No.: RB-05L012

3. Working voltage: DC 5V

4. Contrast adjustment: potentiometer adjustment

5. Backlight adjustment: program or manual control switch

6. Interface definition: +, -, SDA, SCL

7. Module size: 98×60×21mm

8. Module weight: 78g 9. Mounting hole diameter: 3.5mm

10. Horizontal installation hole center distance: 93mm

11. Vertical installation hole center distance: 55mm

12. Screen size: 98×40×9.8mm

13. Working temperature: -30~+60℃

14. Pin definition:

    SDA:双向数据信号

    SCL:时钟信号

    +:电源(VCC)

    -:地(GND)

insert image description here
Module Reference Circuit Schematic

insert image description here
Wiring diagram of Arduino experiment

insert image description here
Arduino experiment open source code

/*

 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)

实验一百二十七:2004A字符显示液晶模块LCD/LCM 蓝屏5V(带背光 IIC/I2C)

 安装库:工具——管理库——搜索“LiquidCrystal_I2C"——下载安装

 项目一:显示字符“Welcome to Eagler8”

 Arduino------LCD2004A

 5V-------------VCC

 GND-----------GND

 A4-----------SDA IIC 数据线

 A5-----------SCL IIC 时钟线

*/



#include <Wire.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4);

void MyPrintLCD(String MyString)

{
    
    

 for (int i = 0; i < MyString.length(); i++)

  lcd.write(MyString.charAt(i));

}



void setup(){
    
    

 lcd.init();

 lcd.backlight();

 MyPrintLCD(" Welcome to ");

 lcd.setCursor(0, 2);

 MyPrintLCD("      Eagler8");

}



void loop()

{
    
    

}

Arduino experiment scene diagram

insert image description here

Arduino experiment open source code 2

/*

 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)

实验一百二十七:2004A字符显示液晶模块LCD/LCM 蓝屏5V(带背光 IIC/I2C)

 安装库:工具——管理库——搜索“LiquidCrystal_I2C"——下载安装

 项目二:多重显示字符,系列演示

 Arduino------LCD2004A

 5V-------------VCC

 GND-----------GND

 A4-----------SDA IIC 数据线

 A5-----------SCL IIC 时钟线

*/



#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(0x27, 20, 4); // set the LCD address to 0x27 for a 16 chars and 2 line display



void setup(){
    
    

 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.print("Hello world...");

 lcd.setCursor(0, 1);

 lcd.print(" i ");

 lcd.printByte(3);

 lcd.print(" arduinos!");

 delay(5000);

 displayKeyCodes();

}

// display all keycodes

void displayKeyCodes(void) {
    
    

 uint8_t i = 0;

 while (1) {
    
    

  lcd.clear();

  lcd.print("Codes 0x"); lcd.print(i, HEX);

  lcd.print("-0x"); lcd.print(i + 16, HEX);

  lcd.setCursor(0, 1);

  for (int j = 0; j < 16; j++) {
    
    

   lcd.printByte(i + j);

  }

  i += 16;

  delay(4000);

 }

}



void loop()

{
    
    

}

Arduino experiment scene diagram

insert image description here
insert image description here
Experimental open source graphics programming (Mind+, programming while learning)

insert image description here
insert image description here
Experimental open source simulation programming (Linkboy V4.62)

insert image description here
insert image description here

Arduino experiment open source code 3

/*

 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)

实验一百二十七:2004A字符显示液晶模块LCD/LCM 蓝屏5V(带背光 IIC/I2C)

 使用步骤:

 1.先下载GY25_uart程序至arduino

 2.再接上GY25模块

 3.按复位按键

 4.打开串口,波特率115200

 5、接线

 GY25        arduino uno

 VCC----------------------VCC

 RX-----------------------TX

 TX-----------------------RX

 GND----------------------GND

 ---------------------------------------

 IICLCD2004      arduino uno

 VCC----------------------VCC

 SCL----------------------A5

 SDA----------------------A4

 GND----------------------GND

 实验之三:IICLCD2004显示动态角度数值

*/



#include <Wire.h>

#include <LiquidCrystal_I2C.h>

int YPR[3];

unsigned char Re_buf[8], counter = 0;

unsigned char sign = 0;

int led = 13;

LiquidCrystal_I2C lcd(0x27, 20, 4); // set the LCD address to 0x20 for a 20 chars and 4 line display



void setup(){
    
    

 lcd.init();           // initialize the lcd

 // Print a message to the LCD.

 Serial.begin(115200);

 delay(2000);

 Serial.write(0XA5);

 Serial.write(0X52);  //初始化GY25,连续输出模式

 lcd.backlight();

 lcd.setCursor(0, 0);  //I2C接口LCD2004显示初始值

 lcd.print("Yaw:");

 lcd.setCursor(0, 1);

 lcd.print("Pitch:");

 lcd.setCursor(0, 2);

 lcd.print("Roll:");

}



void loop() {
    
    

 if (sign)

 {
    
    

  sign = 0;

  if (Re_buf[0] == 0xAA && Re_buf[7] == 0x55)  //检查帧头,帧尾

  {
    
    

   YPR[0] = (Re_buf[1] << 8 | Re_buf[2]) / 100; //合成数据,去掉小数点后2位

   YPR[1] = (Re_buf[3] << 8 | Re_buf[4]) / 100;

   YPR[2] = (Re_buf[5] << 8 | Re_buf[6]) / 100;

   lcd.setCursor(4, 0);

   lcd.print("  ");

   lcd.setCursor(4, 0);

   lcd.print(YPR[0]);   //显示航向

   lcd.setCursor(6, 1);

   lcd.print("  ");

   lcd.setCursor(6, 1);  //显示俯仰角

   lcd.print(YPR[1]);

   lcd.setCursor(5, 2);

   lcd.print("  ");

   lcd.setCursor(5, 2);  //显示横滚角

   lcd.print(YPR[2]);

   delay(100);

  }

 }

}



void serialEvent() {
    
    

 while (Serial.available()) {
    
    

  Re_buf[counter] = (unsigned char)Serial.read();

  if (counter == 0 && Re_buf[0] != 0xAA) return; // 检查帧头

  counter++;

  if (counter == 8)       //接收到数据

  {
    
    

   counter = 0;        //重新赋值,准备下一帧数据的接收

   sign = 1;

  }

 }

}

Arduino experiment scene diagram

insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/131376944