Wemos D1 1602 液晶屏幕
作者:互联网
接线: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