|
|

楼主 |
发表于 2016-1-22 20:36:17
|
显示全部楼层
- //dht11 data=pin2
- //lcd1602 scl=A5;sda=A4
- #include <dht11.h>
- dht11 DHT11;
- #define DHT11PIN 2
- #include <Wire.h>
- #include <LiquidCrystal_I2C.h>
- LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
- void setup() {
- Serial.begin (9600);
- lcd.init(); // initialize the lcd
- lcd.init(); // initialize the lcd
- lcd.backlight(); //Open the backlight
- }
- void loop() {
- int t=DHT11.read(DHT11PIN);
- Serial.print("Humidity (%): ");
- Serial.println((float)DHT11.humidity, 2);
- Serial.print("Temperature (oC): ");
- Serial.println((float)DHT11.temperature, 2);
- // put your main code here, to run repeatedly:
- lcd.clear();
- delay(2000);
- lcd.print("T is :");
- lcd.print((float)DHT11.temperature, 2);
- lcd.print("C");
- lcd.setCursor(0,1);
- lcd.print("H is :");
- lcd.print((float)DHT11.humidity, 2);
- lcd.print("%");delay(2000);
-
- }
复制代码 已经开始怀疑我的lcd有问题了,所有的程序都是不能下一个,从程序下载到arduino板上面开始,lcd
就没有显示,只有转动后面的i2c的调节对比度旋钮才能显示,数据不能刷新 |
|