概述

Arduino控制器的控制端口数量实在是有限,连接几个传感器,通讯设备什么的,你就会发现端口不够用了,还想扩展一个液晶显示器,怎么办? 为了解决上述问题,我们开发的I2C接口的LCD显示器,I2C只需两根线就可以实现数据显示,还可以串联多个I2C设备。标准IIC接口,除了Arduino可以使用之外,其他单片机同样可以进行驱动控制。 I2C LCD1602液晶模块,可以显示2行,每行16个字符。对于Arduino初学者来说,不必为繁琐复杂液晶驱动电路连线而头疼了,这款LCD扩展板将电路简化,使用相关文档中的库文件,您只需使用几行简单的Arduino控制代码便能完成LCD控制显示的功能。 I2C LCD1602液晶模块背面的电位器还能提供你调节液晶显示器对比度的功能。 新版的IIC LCD模块支持gadgeteer接口,并且具有地址设置功能,可以通过跳线设置地址(0x20-0x27)。

技术规格

接口定义

I2C_LCD_Module_V1.1_4.jpg

地址设置

A2 A1 A0 地址
0 0 0 0x20
0 0 1 0x21
0 1 0 0x22
0 1 1 0x23
1 0 0 0x24
1 0 1 0x25
1 1 1 0x26
1 1 1 0x27

短路帽插上为0,拔掉为1。

连线图

I2C LCD 连线图

在你的Arduino连接SDA的引脚4和SCL的引脚5

库函数

示例代码

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>

    #if defined(ARDUINO) && ARDUINO >= 100
    #define printByte(args)  write(args);
    #else
    #define printByte(args)  print(args,BYTE);
    #endif

    LiquidCrystal_I2C lcd(0x20,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以及以上版本)

LCD数据手册CN

LCD Datasheet

原理图

相关项目

<File:nextredirectltr.png>购买 IIC/TWI LCD1602液晶模块(SKU:TOY0046)

category: Product Manual category: DFR Series category: Modules category: source category: Diagram