“实验三十二:LCD1602 IIC显示实验”的版本间的差异

来自丢石头百科
(创建页面,内容为“首页 == Arduino == === 电路连接 === *600px === 扫描设…”)
 
第1行: 第1行:
 
[[Basic Experiment Kits For Arduino|首页]]
 
[[Basic Experiment Kits For Arduino|首页]]
 +
== 模块说明 ==
 
== Arduino ==
 
== Arduino ==
 
=== 电路连接 ===
 
=== 电路连接 ===

2024年8月22日 (四) 15:52的版本

首页

模块说明

Arduino

电路连接

  • 实验三十二:LCD1602 IIC显示实验 接线1.png

扫描设备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);
}

树莓派

实验现象

电路连接

程序运行

C语言

Python

例程下载

相关例程

Arduino和树莓派基础实验套件例程
教程名2
  • 列表2
教程名3
  • 列表3
教程名4
  • 列表4
教程名5
  • 列表5
教程名6
  • 列表6