(SKU:DFR0063)IIC/TWI LCD1602液晶模块
来自DFRobot Product Wiki
目录 |
概述
Arduino控制器的控制端口数量实在是有限,连接几个传感器,通讯设备什么的,你就会发现端口不够用了,还想扩展一个液晶显示器,怎么办?
为了解决上述问题,我们开发的I2C接口的LCD显示器,I2C只需两根线就可以实现数据显示,还可以串联多个I2C设备。标准IIC接口,除了Arduino可以使用之外,其他单片机同样可以进行驱动控制。
IIC LCD1602液晶模块,可以显示2行,每行16个字符。对于Arduino初学者来说,不必为繁琐复杂液晶驱动电路连线而头疼了,这款LCD扩展板将电路简化,使用相关文档中的库文件,您只需使用几行简单的Arduino控制代码便能完成LCD控制显示的功能。I2C LCD1602液晶模块背面的电位器还能提供你调节液晶显示器对比度的功能。
技术规格
- 模块供电电压:5v
- 接口: I2C / TWI 两线数据通讯
- I2C接口通讯地址:0x27
- 背光:蓝色,白色字符
- 尺寸: 82x35x18mm
- 重量: 40g
对比度调整
连线图
在你的Arduino连接SDA的引脚4和SCL的引脚5
库函数
- LiquidCrystal()
- begin()
- clear()
- home()
- setCursor()
- write()
- print()
- cursor()
- noCursor()
- blink()
- noBlink()
- display()
- noDisplay()
- scrollDisplayLeft()
- scrollDisplayRight()
- autoscroll()
- noAutoscroll()
- leftToRight()
- rightToLeft()
- createChar()
示例代码
Download Sample code and library
//DFRobot.com //Compatible with the Arduino IDE 1.0 //Library version:1.1 #include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); lcd.print("Hello, world!"); } void loop() { } </source> <br> Sample sketch: Control the back light of the I2C LCD1602 Module <source lang="cpp"> #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 LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup(){ lcd.init(); // initialize the lcd lcd.backlight(); lcd.home(); lcd.print("Hello world..."); lcd.setCursor(0, 1); lcd.print("dfrobot.com"); } int backlightState = LOW; long previousMillis = 0; long interval = 1000; void loop(){ unsigned long currentMillis = millis(); if(currentMillis - previousMillis > interval) { previousMillis = currentMillis; if (backlightState == LOW) backlightState = HIGH; else backlightState = LOW; if(backlightState == HIGH) lcd.backlight(); else lcd.noBacklight(); } }
相关资料
Arduino I2C LCD库(兼容Arduino IDE 1.0以及以往版本)