极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11845|回复: 2

《求助》关于lcd 1602 i2c

[复制链接]
发表于 2016-1-22 17:51:36 | 显示全部楼层 |阅读模式
lcd不能自动刷新,借鉴网络上面的程序也是不能刷新,需要调节背后的对比度旋钮才能看到刷新以后的文字
#include<Wire.h>
#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
void setup()
{ lcd.init();
  lcd.setCursor(0,0);
lcd.print("www.geeetech.com");
  lcd.backlight();
}
void loop()
{
int i;
for(i=0;i<9;i++)
{
lcd.setCursor(0,1);
lcd.print(i);
delay(1000);
}
}
回复

使用道具 举报

发表于 2016-1-22 18:07:39 | 显示全部楼层
我是用写空白的方法“刷新"的。

写空白;
写i;
delay;

循环。。。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-1-22 20:36:17 | 显示全部楼层
  1. //dht11 data=pin2
  2. //lcd1602 scl=A5;sda=A4
  3. #include <dht11.h>
  4. dht11 DHT11;
  5. #define DHT11PIN 2
  6. #include <Wire.h>
  7. #include <LiquidCrystal_I2C.h>
  8. LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

  9. void setup() {
  10.   Serial.begin (9600);
  11.   lcd.init(); // initialize the lcd

  12. lcd.init(); // initialize the lcd

  13. lcd.backlight(); //Open the backlight
  14. }
  15. void loop() {
  16.   int t=DHT11.read(DHT11PIN);
  17.   Serial.print("Humidity (%): ");
  18.   Serial.println((float)DHT11.humidity, 2);
  19.   Serial.print("Temperature (oC): ");
  20.   Serial.println((float)DHT11.temperature, 2);
  21. // put your main code here, to run repeatedly:
  22.   lcd.clear();
  23.   delay(2000);
  24.   lcd.print("T is :");
  25.   lcd.print((float)DHT11.temperature, 2);
  26.   lcd.print("C");
  27.   lcd.setCursor(0,1);
  28.   lcd.print("H is :");
  29.   lcd.print((float)DHT11.humidity, 2);
  30.   lcd.print("%");delay(2000);
  31.   
  32. }
复制代码
已经开始怀疑我的lcd有问题了,所有的程序都是不能下一个,从程序下载到arduino板上面开始,lcd
就没有显示,只有转动后面的i2c的调节对比度旋钮才能显示,数据不能刷新
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-7 00:23 , Processed in 0.043099 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表