一、简介
LCD1602/2004液晶屏转接板模块采用MCP2308芯片,通过IIC接口扩展8路通用双向IO口。可以为较少IO口的单片机扩展IO口,还可以作为LCD1602、LCD2004液晶屏提供简化的接线方案。由于采用IIC通信,可以在IIC总线上挂载多个LCD1602、LCD2004液晶屏或扩展更多的通用IO引脚,大大减少了主控单片机的IO口,使得扩展更加容易。
二、内部逻辑图
三、引脚说明
PH2.0 4P插座接口
V | 电源正极 |
---|---|
G | 电源负极 |
C | IIC接口时钟信号线SCL |
D | IIC接口数据信号线SDA |
四、原理图
五、器件地址
六、使用方法
实验准备
LCD1602/2004液晶屏转接板模块 | 1个 |
---|---|
原装正版Arduino uno r3开发板 | 1个 |
1602 LCD液晶屏 5.0V 黄绿屏 | 1个 |
USB2.0打印机数据线高速方口连接转接线 A公对B公 | 1条 |
杜邦线 | 若干 |
接线
Arduino | LCD1602/2004液晶屏转接板模块 |
---|---|
5V | V |
GND | G |
SCL | C |
SDA | D |
程序下载
/*
Demonstration sketch for Adafruit i2c/SPI LCD backpack
using MCP23008 I2C expander
( http://www.ladyada.net/products/i2cspilcdbackpack/index.html )
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit for Duemilanove
* 5V to Arduino 5V pin
* GND to Arduino GND pin
* CLK to Analog #5
* DAT to Analog #4
For other boards, use the following chart (CLK=SCL,DAT=SDA)
Board I2C / TWI pins
--------- --------------------------
Uno, Yun A4 (SDA), A5 (SCL)
Mega2560 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
Due 20 (SDA), 21 (SCL)
*/
// include the library code:
#include <Wire.h>
#include "LiquidTWI2.h"
// Connect via i2c, address 0x20 (A0-A2 not jumpered)
LiquidTWI2 lcd(0x20);
void setup() {
// set the LCD type
lcd.setMCPType(LTI_TYPE_MCP23008);
// lcd.setMCPType(LTI_TYPE_MCP23017);
// set up the LCD's number of rows and columns:
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);
lcd.setBacklight(HIGH);
delay(500);
lcd.setBacklight(LOW);
delay(500);
}
实验现象