ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Wemos D1 1602 液晶屏幕

2021-08-14 15:34:25  阅读:207  来源: 互联网

标签:16 void 1602 Wemos lcd address Serial include 液晶屏幕


 

 接线:GND 5V D14 D15

 1 #include <Wire.h> 
 2 #include <LiquidCrystal_I2C.h>
 3 
 4 LiquidCrystal_I2C lcd(0x3F,16,2);  // 设置液晶地址 0x27  设置一行显示的字符 16个 2 行显示
 5 
 6 void setup()
 7 {
 8   lcd.init();                      //初始化
 9  
10   // Print a message to the LCD.
11   lcd.backlight();   //打开背光
12   lcd.print("Hello, world!");  //输出内容
13 }
14 
15 void loop()
16 {
17 }

注意,液晶地址可能不同,无法点亮

地址查询

 1 #include <Wire.h>
 2 
 3 
 4 void setup()
 5 {
 6 Wire.begin();
 7 
 8 Serial.begin(9600);
 9 Serial.println("\nI2C Scanner");
10 }
11 
12 
13 void loop()
14 {
15 byte error, address;
16 int nDevices;
17 
18 Serial.println("Scanning...");
19 
20 nDevices = 0;
21 for(address = 1; address < 127; address++ )
22 {
23 // The i2c_scanner uses the return value of
24 // the Write.endTransmisstion to see if
25 // a device did acknowledge to the address.
26 Wire.beginTransmission(address);
27 error = Wire.endTransmission();
28 
29 if (error == 0)
30 {
31 Serial.print("I2C device found at address 0x");
32 if (address<16)
33 Serial.print("0");
34 Serial.print(address,HEX);
35 Serial.println(" !");
36 
37 nDevices++;
38 }
39 else if (error==4)
40 {
41 Serial.print("Unknow error at address 0x");
42 if (address<16)
43 Serial.print("0");
44 Serial.println(address,HEX);
45 }
46 }
47 if (nDevices == 0)
48 Serial.println("No I2C devices found\n");
49 else
50 Serial.println("done\n");
51 
52 delay(5000); // wait 5 seconds for next scan
53 }

 

标签:16,void,1602,Wemos,lcd,address,Serial,include,液晶屏幕
来源: https://www.cnblogs.com/bymeet/p/15140899.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有