danielkepaniel:
Thank you for all your help this really helped me a lot and I learned some new things too and I am grateful for that. I only have one last question. How can I find the address for for my LCD, because I tried using the address I used for my previous code but that didn't work. I am just wondering if there is something on the backpack I should look out for?
// LiquidCrystal compability:
// Since hd44780 is LiquidCrystal API compatible, most existing LiquidCrystal
// sketches should work with hd44780 hd44780_I2Clcd i/o class once the
// includes are changed to use hd44780 and the lcd object constructor is
// changed to use the hd44780_I2Clcd i/o class.
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Clcd.h> // i2c LCD i/o class header
// Note, i2c address can be specified or automatically located
// If you wish to use a specific address comment out this constructor
// and use the constructor below that specifies the address
// declare the lcd object for auto i2c address location
hd44780_I2Clcd lcd;
//
// enter address of LCD.
// Addresses seen so far include:
// - 0x3a, 0x3b (PCF2119x)
// - 0x3c (unknwon chip)
// - 0x3d (unknwon chip)
// - 0x3e (unknwon chip)
// - 0x3f (unknwon chip)
// declare i2c address and constructor for specified i2c address
//const int i2c_addr = 0x3e;
//hd44780_I2Clcd lcd(i2c_addr); // use device at this address
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
void setup()
{
int status;
// initialize LCD with number of columns and rows:
// hd44780 returns a status from begin() that can be used
// to determine if initalization failed.
// the actual status codes are defined in <hd44780.h>
// See the values RV_XXXX
//
// looking at the return status from begin() is optional
// it is being done here to provide feedback should there be an issue
//
status = lcd.begin(LCD_COLS, LCD_ROWS);
if(status) // non zero status means it was unsuccesful
{
// begin() failed so blink error code using the onboard LED if possible
hd44780::fatalError(status); // does not return
}
// Print a message to the LCD
lcd.print("Hello, World!");
}
void loop() {}
You are using the wrong hd44780 i/o class.
In that sketch you are trying to use, just above the code you posted, was this comment:
// This sketch is for LCD modules that have a native I2C interface such as
// PCF2119x, PCF2116, or certain RayStar LCDs rather than those LCD modules that
// use an i/o expander chip based based backpack.
This should have been a clue that this sketch is not for the type of LCD device you are using.
I would recommend taking some time to read hd44780 included documentation.
There is quite a bit of documentation that comes with the library that can be accessed directly from the
IDE under the Documentation example sketch.
Bring up that example, and you bring up the documentation and can click on many other documentation links.
It explains the structure of the library and its examples and has lots of documentation on the type of LCD and backpack that you have.
--- bill