LCD1602

1602液晶显示器(1602 Liquid Crystal Display,此后简称1602 LCD)是一种常见的字符液晶显示器,因其能显示16*2个字符而得名。通常我们使用的1602 LCD中集成了字库芯片,通过LiquidCrystal类库提供的API,我们可以很方便的使用1602LCD显示英文字母与一些符号。

实验材料

  • Stduino UNO开发板
  • 面包板及配套杜邦线
  • LCD1602液晶屏
  • 10K电位器

电路连接

LCD1602接口说明

编号 符号 引脚说明 编号 符号 引脚说明
1 VSS 电源接地 9 D2 Data I/O
2 VDD 电源正极 10 D3 Data I/O
3 VL 液晶显示偏压信号 11 D4 Data I/O
4 RS 数据/命令选择端(HIGH/LOW) 12 D5 Data I/O
5 R/W 读/写选择端(HIGH/LOW) 13 D6 Data I/O
6 E 使能信号 14 D7 Data I/O
7 DO Data I/O 15 BLA 背光源正极
8 D1 Data I/O 16 BLK 背光源负极

其中:

  • VL(V0):液晶对比度调整端,用于调节显示对比度,一般接10K电位器进行调整。
  • RS:数据/命令选择。高电平表示数据,低电平表示命令。
  • RW:读写选择。高电平为读,低电平为写。一般我们写入数据进行显示,所以此引脚接地。
  • EN:使能信号,配合数据/命令的读写。
  • D0-D7:双向数据端。可以使用8根数据线并行操作,也可以使用4根数据线串行操作。

关于LCD1602的驱动也非常简单。官方数据手册给出了基本操作时序和初始化设置步骤。本篇我们为了减少线路连接采用4位串行操作方式,一条8位的数据和命令分两次写入1602。

LCD1602的第1、5、16脚接开发板GND;LCD1602第2、15脚接开发板5V;LCD1602的第4、6、11、12、13、14分别连接开发板数字引脚rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;电位器两端引脚分别连接5V和GND,中间引脚连接LCD1602第3引脚。
注意先按下面步骤安装对应库后,下面的代码才可正常使用

##代码示例

#include <Arduino.h>
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

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);
}

原文链接:https://blog.csdn.net/TonyIOT/article/details/89148117

文档更新时间: 2021-06-19 18:57   作者:admin