Hi Guys, so I have the sainsmart LCD2004 mini board that attaches to the back of the 4x20 LCD blue/white LCD screen. The LCD2004 cuts down the number of connections from the 4x20 screen to only 4 - GND, VCC, SDA, SCL. Using this code, it worked perfectly fine w/ my Uno and scrolled 'Hello World' across the screen.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//PIN CONFIGURATION
//For Uno A4 to SDA , A5 to SCL, VCC to 5v, Gnd To Gnd
//For Mega SDA to 20, SCL to 21LiquidCrystal_I2C lcd(0x3F,20,4);
int iColMax = 20;
int iCol = iColMax;
int iRow = 0;void setup()
{
lcd.init();
lcd.backlight();
}void loop()
{
lcd.clear();
String sPrint = String("Who's the man!!!");
int iStringLength = sPrint.length();
int iWriteLength = iColMax - iCol;
if (iWriteLength >= iStringLength) {iWriteLength = iStringLength;}
sPrint = sPrint.substring(0, iWriteLength);
lcd.setCursor(iCol, iRow);
lcd.print(sPrint);
String sStatusLine = String("Col:") += String(iCol) += String(" Row:") += String(iRow) += String(" Len:") += String(sPrint.length());
lcd.setCursor(0, 3);
lcd.print(sStatusLine);
iCol--;
if (iCol < 0)
{
iCol = iColMax;
iRow++;
if (iRow >= 3) {iRow = 0;}
}
delay(100);
}
So then I swap it over to the mega 2560. Instead of using the A4, A5 pins on the uno, I use the 20,21 pins on the mega which are the SCL, SDA plugs (I also tried it with the A4/A5 pins, but that didn't work either). I always get the same error as soon as I upload:
avrdude: stk500v2_ReceiveMessage(): timeout
So here's the troubleshooting I've done so far:
-
I can't upload any other sketches to the arduino unless I shutdown the arduino IDE & unplug the arduino from my computer.
-
I've used the I2C scanner to make sure I have the correct device address. After unplugging & restarting everything, the I2C scanner runs, and finds a device at address 0x3F. I reload the hello world sketch and get the same error.
It's almost like it's referencing something incorrectly from the LiquidCrystal_I2C library. The LCD lights up (duh...that's easy by just adding power), but the screen only shows lines 1 & 3 as being populated with white squares - like they're waiting for characters. When it's hooked up to the uno...it works fine and all the white squares on the 4x20 LCD screen light up.
Any ideas on how to fix this issue guys?