|
|

楼主 |
发表于 2019-8-11 11:57:44
|
显示全部楼层
- /*
- 【Arduino】66种传感器模块系列实验(88)
- 实验八十八: LCD1602A液晶屏5V显示模块(IIC/I2C接口)
- 项目一:寻找查询设备IIC地址,在串口上即可看到1602的地址
- 这里查询结果是“0x27”(这个地址不对的话,实测无法烧录程序)
- Arduino------LCD1602
- 5V-------------VCC
- GND-----------GND
- A4-----------SDA IIC 数据线
- A5-----------SCL IIC 时钟线
- */
- #include <Wire.h>
-
- void setup(){
- Wire.begin();
- Serial.begin(9600);
- Serial.println("\nI2C Scanner");
- }
- void loop(){
- byte error, address;
- int nDevices;
- Serial.println("Eagler8 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.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);
- }
复制代码 |
|