Arduino 扫描IIC/I2C设备地址代码 附LiquidCrystal_I2C库文件下载

作者:贝壳物联 | 更新时间:2017-07-22

LCD1602 IIC连接显示

Arduino 扫描IIC/I2C设备地址代码

#include "Wire.h"
void setup() {
    Serial.begin (115200); // Leonardo: wait for serial port to connect
    while (!Serial) { }
    Serial.println ();
    Serial.println ("I2C scanner. Scanning ...");
    byte count = 0;
    Wire.begin();
    for (byte i = 8; i < 120; i++) {
        Wire.beginTransmission (i);
        if (Wire.endTransmission () == 0) {
          Serial.print ("Found address: ");
          Serial.print (i, DEC);
          Serial.print (" (0x");
          Serial.print (i, HEX);
          Serial.println (")");
          count++;
          delay (1); // maybe unneeded?
        } // end of good response
    } // end of for loop
    Serial.println ("Done.");
    Serial.print ("Found ");
    Serial.print (count, DEC);
    Serial.println (" device(s).");
} // end of setup
void loop() {}

通过arduino IDE 串口监视器 查看结果如下:

附LiquidCrystal_I2C库文件,此库请在Arduino IDE 经典1.0.x版下使用

LiquidCrystal_I2C.rar

淘宝链接


评论:共1条

a386554965 评论于:2018-06-17 09:23:42
学习一下
评论支持使用[code][/code]标签添加代码
返回顶部