Alfers 发表于 2015-1-8 22:25:02

1602只显示16个方块

本帖最后由 Alfers 于 2015-1-8 22:29 编辑


连线如图片,测量温湿度,但是LCD只显示第一行的16个方块。程序如下。连线检查过N次无误。
/*
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
#include <LiquidCrystal.h>
#include <dht11.h>
#define DHT11PIN 8
dht11 DHT11;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
pinMode(DHT11PIN,OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}

void loop() {
int chk = DHT11.read(DHT11PIN);
lcd.setCursor(0, 0);
lcd.print("Tep: ");
lcd.print((float)DHT11.temperature, 2);
lcd.print("C");
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print("Hum: ");
lcd.print((float)DHT11.humidity, 2);
lcd.print("%");
delay(200);
}

zoologist 发表于 2015-1-9 07:56:29

先确认 1602 是否是好用的

dingoslove 发表于 2015-1-9 09:16:53

显示效果发张图片,看看

lm4766 发表于 2015-1-9 09:46:34

灰度原因。。。。。。。。。。。。。。。。。

Alfers 发表于 2015-1-9 09:50:39

dingoslove 发表于 2015-1-9 09:16 static/image/common/back.gif
显示效果发张图片,看看

Pyrrhus 发表于 2015-1-9 12:35:30

LCD不显示的问题不清楚,但是DHT的写法很有问题:
1.21行的pinMode(DHT11PIN,OUTPUT);
不是要读数据么,为什么要设成OUTPUT?

2.16行的dht11 DHT11;
感觉写反了,一般的写法是DHT11 myDHT11(10);

Alfers 发表于 2015-1-9 12:51:12

Pyrrhus 发表于 2015-1-9 12:35 static/image/common/back.gif
LCD不显示的问题不清楚,但是DHT的写法很有问题:
1.21行的pinMode(DHT11PIN,OUTPUT);
不是要读数据么,为 ...

还是木有解决。anyway, THX!!

56832926 发表于 2015-1-9 13:51:51

调一下LCD的对比度试一下:)

ethan42411 发表于 2015-1-9 17:28:52

先點個Hello World試試看

布列松 发表于 2015-1-9 20:17:20

用 I2C 模块吧 好多的

suoma 发表于 2015-1-10 22:10:17

Pyrrhus 发表于 2015-1-9 12:35 static/image/common/back.gif
LCD不显示的问题不清楚,但是DHT的写法很有问题:
1.21行的pinMode(DHT11PIN,OUTPUT);
不是要读数据么,为 ...

同意楼上观点

suoma 发表于 2015-1-10 22:11:24

应该是初始化问题

suoma 发表于 2015-1-10 22:12:02

感觉应该有个read指令

jhyeqf 发表于 2015-1-11 01:09:07

我碰到过这个问题,但我用的是I2C模块,我觉得有共性,你可以参考下本论坛
i2C 1602 [ LCD1602转接板 Arduino IIC ]没显示一例
http://www.geek-workshop.com/thread-10950-1-1.html

我也是觉得你的LCD设置有问题,希望对你有帮助

56832926 发表于 2015-1-16 09:53:36

我试了一下,没有问题。你调整一下对比度应该就可以了
页: [1] 2
查看完整版本: 1602只显示16个方块