【新手求助】mega2560 i2c连接 lcd 2004
我有一块lcd2004的板子用了i2c的转接芯片,连接在mega2560上的20 21口。但是刷写示例程序后无法显示任何内容,只有两行白块。之前连接i2c的lcd1602的时候也遇到了同样的问题,该如何解决? 代码放上来 Damn_intuition 发表于 2013-3-14 19:30 static/image/common/back.gif代码放上来
//DFRobot.com
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args)write(args);
#else
#define printByte(args)print(args,BYTE);
#endif
uint8_t bell= {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
uint8_t note= {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
uint8_t clock = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
uint8_t heart = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
uint8_t duck= {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
uint8_t check = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t cross = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
uint8_t retarrow = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
LiquidCrystal_I2C lcd(0x27,20,4);// set the LCD address to 0x27 for a 20 chars and 4 line display
void setup()
{
//Serial.begin(57600);
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.createChar(0, bell);
lcd.createChar(1, note);
lcd.createChar(2, clock);
lcd.createChar(3, heart);
lcd.createChar(4, duck);
lcd.createChar(5, check);
lcd.createChar(6, cross);
lcd.createChar(7, retarrow);
lcd.home();
lcd.setCursor(0, 0);
for(int i = 0;i < 20; i++)lcd.printByte(6);
lcd.setCursor(0, 1);
lcd.printByte(6);
lcd.print(" Hello world ");
lcd.printByte(6);
lcd.setCursor(0, 2);
lcd.printByte(6);
lcd.print("i ");
lcd.printByte(3);
lcd.print(" arduinos! ");
lcd.printByte(6);
lcd.setCursor(0, 3);
for(int i = 0;i < 20; i++)lcd.printByte(6);
//lcd.clear();
}
void loop()
{
}
loop里写代码,setup的只执行一次,效果应该是一闪而过 毛毛毛毛毛 发表于 2013-3-15 13:26 static/image/common/back.gif
试试将
lcd.init();
改为
lcd.init();
delay(200);
lcd.init();
哟~少年……试试这个库吧……有的屏的转接板走线有变化,需要特殊的库…… 谢谢各位,我的问题解决了。
LiquidCrystal_I2C lcd(0x20,20,4);
才是正解
页:
[1]