我们不仅销售产品,我们还传播知识
商品分类

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

经过本人测试有效,特地写出教程供广大爱好者阅读。

第一步:.连线arduino和LCD1602显示器

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

 
LCD1602—–arduino uno

GND ———— GND

VCC ———— 5V

SDA ———— A4

SCL ———— A5

 

第二部,上传程序

#include <Wire.h>

void setup()

{

Wire.begin();

Serial.begin(9600);

Serial.println(” I2C 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 “);

else

Serial.println(“done “);

delay(5000); // wait 5 seconds for next scan

}

第三部,打开串口监视

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

通过上面我们已经可以看到扫描的结果了。

 

创建日期:2018.05.06

更新日期:2022.02.19

发表回复

登录后才能评论

评论列表(1条)

微信群
微信群
联系我们

联系我们

微信:13823392571

在线咨询:点击这里给我发消息

工作时间:周一至周五,9:30-18:30,节假日休息

微信客服
微信客服
分享本页
返回顶部