I have succeeded in getting this display working on a MEGA2560 board by studying other's troubles with this display.
However, I have a question that might be very important.
When one initializes the LiquidCrystal library with a:
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
(Which works)
Doesn't that mean that ports 0, 1, 2, 3, 4, 5, 6 and 7 will not be able to be used by other purposes, even though the LCD2004 IIC doesn't even use any of those ports?
.... Here is my working program and details on how I got it working with that difficult display:
"I succeeded in getting the newest LiquidCrystal v1.3.4 to work with an ATMEGA2560 Board:
Be aware that there are many different versions of the LiquidCrystal Library out there, and many of them have routines which no longer work like init() and other commands which worked under earlier versions.
Unfortunately, they also didn't document just how you use these functions with a MEGA and a LCD2004 IIC at all. This makes it exceedingly difficult to get it to work correctly with this display.
However, it's simpler than it looks.
Hitch VCC, GND and the two wires coming from pins 20 (SDA, or the Serial Data Line) and 21 (SCL, the Serial Clock) from the MEGA2570 board (I'm using a cheap, no-name, Chinese version of the MEGA).
Remove all other folders that are LiquidCrystal folders from the libraries folder and save them someplace safe in case you need to replace them again.
Shut down the Arduino program.
Create a folder in the libraries folder (mine was at C:\Program Files (x86)\Arduino\libraries\ called NewliquidCrystal
Download and unpack the (large) zip file called NewliquidCrystal_1.3.4.zip file somewhere (or, possibly, the most recent version they have created; but be careful)
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/
Then, copy ONLY the examples folder (not all will work), I2CIO.cpp, I2CIO.h, keywords.txt, LiquidCrystal_12C.cpp and LiquidCrystal_I2C.h to the newly-created folder in the libraries folder that you just made.
Now, you can run the Arduino program again.
Copy-and-paste this code into your Sketch.
If your display has a PCF8574, use 0x27 for the 12C value, if it is PCF8574AT, use 0x3F (Read it off the IC on the back of your display)
// ===================== Begin Code =====================
#include <LiquidCrystal_I2C.h>
#include <LCD.h>
#include <Wire.h>
// Set the LCD I2C address
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup()
{
lcd.begin(40,4); // initialize the lcd
lcd.display();
lcd.clear(); // Clears the Screen
lcd.home (); // Probably Redundant
// Print a message to the LCD.
//lcd.setCursor(Column minus 1, Row minus 1);
lcd.noBlink(); // Turn off blinking cursor
lcd.setCursor(1,0);
lcd.print("Well, Well, Well...");
lcd.setCursor(6,1);
lcd.print("TheWind777");
lcd.setCursor(6,2);
lcd.print("Succeeded");
lcd.setCursor(4,3);
lcd.print("On 4/15/2017");
lcd.display(); // Turns on the Display
}
void loop()
{
// Turn off the display:
lcd.noDisplay();
delay(1000);
// Turn on the display:
lcd.display();
delay(1000);
}
// ====================== End Code ======================