极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 14317|回复: 8

1602LCD无法正常显示~

[复制链接]
发表于 2014-2-4 23:03:47 | 显示全部楼层 |阅读模式
本帖最后由 zxyy15717 于 2014-2-5 19:04 编辑

连接之后调电位器出的是下面这种效果:

调电位器只能把小白块整体调没有或调出,就是无法正常显示字符。

对着参考书和论坛群主的帖子仔细检查了,连线是一定没有问题的,不知道是哪里出了差错~~我买的LCD是没带脚针的,所以下面用了个东西垫一下高度避免接触不良。这个也不应该是接触不良的问题吧??

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2014-2-4 23:42:18 | 显示全部楼层
无代码,无接线图
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-2-4 23:57:36 | 显示全部楼层
davidce 发表于 2014-2-4 23:42
无代码,无接线图

http://www.geek-workshop.com/thread-78-1-1.html
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-2-5 00:08:53 | 显示全部楼层
davidce 发表于 2014-2-4 23:42
无代码,无接线图

我自己也有用官方的liquidcrystal库的测试程序。
代码如下(RW口直接接地,所以代码里没有设计,pin12接RS引脚,pin11接使能端,pin6到pin9对应D4到D7)
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 10, 6, 7, 8, 9); // Create an lcd object and assign the pins
void setup() {
lcd.begin(16, 2); // Set the display to 16 columns and 2 rows
}
void loop() {
// Run the seven demo routines
basicPrintDemo();
displayOnOffDemo();
setCursorDemo();
scrollLeftDemo();
scrollRightDemo();
cursorDemo();
createGlyphDemo();
}
void basicPrintDemo() {
lcd.clear(); // Clear the display
lcd.print("Basic Print"); // Print some text
delay(2000);
}
void displayOnOffDemo() {
lcd.clear(); // Clear the display
lcd.print("Display On/Off"); // Print some text
for(int x=0; x < 3; x++) { // Loop 3 times
lcd.noDisplay(); // Turn display off
delay(1000);
lcd.display(); // Turn it back on again
delay(1000);
}
}

void setCursorDemo() {
lcd.clear(); // Clear the display
lcd.print("SetCursor Demo"); // Print some text
delay(1000);
lcd.clear(); // Clear the display
lcd.setCursor(5,0); // Cursor at column 5 row 0
lcd.print("5,0");
delay(2000);
lcd.setCursor(10,1); // Cursor at column 10 row 1
lcd.print("10,1");
delay(2000);
lcd.setCursor(3,1); // Cursor at column 3 row 1
lcd.print("3,1");
delay(2000);
}


void scrollLeftDemo() {
lcd.clear(); // Clear the display
lcd.print("Scroll Left Demo");
delay(1000);
lcd.clear(); // Clear the display
lcd.setCursor(7,0);
lcd.print("Beginning");
lcd.setCursor(9,1);
lcd.print("Arduino");
delay(1000);
for(int x=0; x<16; x++) {
lcd.scrollDisplayLeft(); // Scroll display left 16 times
delay(250);
}
}

void scrollRightDemo() {
lcd.clear(); // Clear the display
lcd.print("Scroll Right");
lcd.setCursor(0,1);
lcd.print("Demo");
delay(1000);
lcd.clear(); // Clear the display
lcd.print("Beginning");
lcd.setCursor(0,1);
lcd.print("Arduino");
delay(1000);
for(int x=0; x<16; x++) {
lcd.scrollDisplayRight(); // Scroll display right 16 times
delay(250);
}
}

void cursorDemo() {
lcd.clear(); // Clear the display
lcd.cursor(); // Enable cursor visible
lcd.print("Cursor On");
delay(3000);
lcd.clear(); // Clear the display
lcd.noCursor(); // Cursor invisible
lcd.print("Cursor Off");
delay(3000);
lcd.clear(); // Clear the display
lcd.cursor(); // Cursor visible
lcd.blink(); // Cursor blinking
lcd.print("Cursor Blink On");
delay(3000);
lcd.noCursor(); // Cursor invisible
lcd.noBlink(); // Blink off
}

void createGlyphDemo() {
lcd.clear();
byte happy[8] = { // Create byte array with happy face
B00000,
B00000,
B10001,
B00000,
B10001,
B01110,
B00000,
B00000};
byte sad[8] = { // Create byte array with sad face
B00000,
B00000,
B10001,
B00000,
B01110,
B10001,
B00000,
B00000};
lcd.createChar(0, happy); // Create custom character 0
lcd.createChar(1, sad); // Create custom character 1

for(int x=0; x<5; x++) { // Loop animation 5 times
lcd.setCursor(8,0);
lcd.write(0); // Write custom char 0
delay(1000);
lcd.setCursor(8,0);
lcd.write(1); // Write custom char 1
delay(1000);
}
}
回复 支持 反对

使用道具 举报

发表于 2014-2-5 11:38:14 | 显示全部楼层
我的测试代码,很简单,你参考一下
#include <LiquidCrystal.h>   //调用arduino自带的LiquidCrystal库1602
LiquidCrystal lcd(8, 7, 6, 5, 4, 3);//设置接口
int a=2;
void setup()
{
  lcd.begin(16, 2);  //初始化LCD
  lcd.clear(); //清屏
  lcd.setCursor(4, 1) ;
lcd.print("start"); //一开始固定显示命令
delay(1000); //延时1000ms
}//把不变化的变量放清屏后面,且void loop不断更新执行,可以藏进setup

void loop ()                     
{
a++;   
lcd.setCursor(0, 0) ; //第二行第一个显示位置
lcd.print("I love you huan");
lcd.setCursor(0, 1) ; //设置光标位置为第二行第一个位置
lcd.print(a); //显示字母C
delay(500);                     //延时2秒,这里也就是刷新速度。
}  
回复 支持 反对

使用道具 举报

发表于 2014-2-5 11:40:17 | 显示全部楼层
代码如下(RW口直接接地,所以代码里没有设计,pin12接RS引脚,pin11接使能端,pin6到pin9对应D4到D7)
#include <LiquidCrystal.h>
// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 10, 6, 7, 8, 9); // Create an lcd object and assign the pins



接的D4~7,代码里却是6~9
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-2-5 14:38:49 | 显示全部楼层
davidce 发表于 2014-2-5 11:40
代码如下(RW口直接接地,所以代码里没有设计,pin12接RS引脚,pin11接使能端,pin6到pin9对应D4到D7)
#i ...

额...可能是我没表达清楚.6-9是arduino板子上的接口,然后接的是lcd上的d4到d7~~
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-2-5 19:04:25 | 显示全部楼层
lm4766 发表于 2014-2-5 11:38
我的测试代码,很简单,你参考一下
#include    //调用arduino自带的LiquidCrystal库1602
LiquidCrystal  ...

结果貌似还是接触有问题...今天有调了调lcd的位置,然后动了动电位器,就显示出来了....下次还是先焊接上脚针再来做....
回复 支持 反对

使用道具 举报

发表于 2014-2-7 11:11:26 | 显示全部楼层
zxyy15717 发表于 2014-2-5 19:04
结果貌似还是接触有问题...今天有调了调lcd的位置,然后动了动电位器,就显示出来了....下次还是先焊接上脚 ...

个人觉得arduino的LiquidCrystal.h库写的比较好。但是感觉STM32各方面秒杀arduino
回复 支持 反对

使用道具 举报

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

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-5-18 10:58 , Processed in 0.040489 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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