太极创客:http://www.taichi-maker.com/homepage/reference-index/arduino-library-index/wire-library/
获取从设备的I2C的地址:https://playground.arduino.cc/Main/I2cScanner/
获取从设备的I2C的地址代码:
#include <Wire.h> void setup() { Wire.begin(); Serial.begin(115200); Serial.println(" I2C Scanner"); } void loop() { byte error, address; int nDevices; Serial.println("Scanning..."); nDevices = 0; for(address = 1; address < 127; address++ ) { Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); nDevices++; } else if (error==4) { Serial.print("Unknow error at address 0x"); if (address<16) { Serial.print("0"); } Serial.println(address,HEX); } } if (nDevices == 0) { Serial.println("No I2C devices found "); } else { Serial.println("done "); } delay(5000); }