“实验三十二:LCD1602 IIC显示实验”的版本间的差异
来自丢石头百科
Yousimaier17(讨论 | 贡献) (→背光选择) |
Yousimaier17(讨论 | 贡献) |
||
第4行: | 第4行: | ||
*通过蓝色电位器调节对比度,蓝色电位器朝上,顺时针减弱,逆时针增强。其中: | *通过蓝色电位器调节对比度,蓝色电位器朝上,顺时针减弱,逆时针增强。其中: | ||
**电位器顺时针选择到底,显示: | **电位器顺时针选择到底,显示: | ||
− | *** | + | ***[[File:实验三十二:LCD1602 IIC显示实验_对比度1.png|400px]] |
**电位器逆时针选择到底,显示: | **电位器逆时针选择到底,显示: | ||
− | *** | + | ***[[File:实验三十二:LCD1602 IIC显示实验_对比度2.png|400px]] |
*当调节电位器至合适位置后,显示如下情况时: | *当调节电位器至合适位置后,显示如下情况时: | ||
− | * | + | *[[File:实验三十二:LCD1602 IIC显示实验_对比度3.png|400px]] |
**检查接线是否松动 | **检查接线是否松动 | ||
**检查IIC设备地址是否设置正确 | **检查IIC设备地址是否设置正确 | ||
第16行: | 第16行: | ||
*可通过一位拨码开关设置是否带背光灯。 | *可通过一位拨码开关设置是否带背光灯。 | ||
**拨码开关拨向ON时,打开背光 | **拨码开关拨向ON时,打开背光 | ||
− | *** | + | ***[[File:实验三十二:LCD1602 IIC显示实验_背光2.png|400px]] |
**拨码开关拨向OFF时,关闭背光 | **拨码开关拨向OFF时,关闭背光 | ||
− | *** | + | ***[[File:实验三十二:LCD1602 IIC显示实验_背光1.png|400px]] |
=== 地址选择 === | === 地址选择 === |
2024年8月22日 (四) 16:51的版本
目录
模块说明
对比度调节
背光选择
地址选择
Arduino
电路连接
扫描设备IIC地址
实验现象
- 串口打印PCF8574的地址
主要程序
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
LCD显示
实验现象
- LCD1602第一行显示LCD1602 iic Test
- LCD1602第二行显示by Diustou
主要程序
//LingShun lab #include <Wire.h> #include <LiquidCrystal_I2C.h> //引用I2C库 LiquidCrystal_I2C lcd(0x20,16,2); //此处修改IIC地址 void setup() { lcd.init(); // 初始化LCD lcd.backlight(); //设置LCD背景等亮 } void loop() { lcd.setCursor(0,0); //设置显示指针 lcd.print("LCD1602 iic Test"); //输出字符到LCD1602上 lcd.setCursor(0,1); lcd.print(" by DIUSTOU"); delay(1000); }