victor 发表于 2019-4-8 16:18:34

如何用Arduino查询LCD1602液晶屏 I2C的初始地址是0x3f还是0x27?

经过本人测试有效,特地写出教程供广大爱好者阅读。第一步:.连线arduino和LCD1602显示器LCD1602—–arduino unoGND ———— GNDVCC ———— 5VSDA ———— A4SCL ———— A5第二部,上传程序#include <Wire.h> void setup(){Wire.begin();Serial.begin(9600);Serial.println("\nI2C Scanner");}void loop(){byte error, address;int nDevices;Serial.println("Scanning...");nDevices = 0;for (address = 1; address < 127; address++ ){    // The i2c_scanner uses the return value of    // the Write.endTransmisstion to see if    // a device did acknowledge to the 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.print(address, HEX);      Serial.println(" !");      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\n");else    Serial.println("done\n");delay(5000); // wait 5 seconds for next scan}第三部,打开串口监视https://img.xiaodingchui.com/2018/09/s-1.png通过上面我们已经可以看到扫描的结果了。

victor 发表于 2019-4-8 16:25:08

原文 https://www.xiaodingchui.com/7831
页: [1]
查看完整版本: 如何用Arduino查询LCD1602液晶屏 I2C的初始地址是0x3f还是0x27?