/* * helloi2c */ #include // standard i2c arduino lib #include "LCDi2c4bit.h" // this is our new library, note quite in 'system space' yet /* * create an instance of the lcd i2c 4bit class. * * this does a lot of stuff! you get back a 'filled in' variable called 'lcd' * and the screen is initialized and ready for you to write to. */ #define backlightPin 9 // a pwm-capable pin, so I picked #9 LCDI2C4Bit lcd = LCDI2C4Bit(0xa7, 2, 16, backlightPin); //0xa7 is the hardware addr of the i2c chip /* * in arduino-land, there is always a setup(). this is ours. */ void setup() { /* * we have to join the i2c bus. just call this routine at the top, as well. */ Wire.begin(); /* * start of useful example program */ lcd.init(); // lets start with a clear screen (never assume it comes to you, clean) lcd.clear(); // turn on backlight, full blast lcd.backLight(255); // explicitly set our cursor position lcd.cursorTo(0, 0); // first row, first column // print the text 'here' at last-set cursor pos lcd.print("LinuxWorks Labs"); // pause a bit delay(3000); // re-clear our display lcd.clear(); /* * print more stuff and then exit */ lcd.cursorTo(0, 0); // first row, first column lcd.print("Hello LinuxWorks"); lcd.cursorTo(1, 0); // 2nd row, first column lcd.print("i2c LCD working!"); // pause a bit more delay(3000); } /* * in arduino-land, there is always a loop(). this is ours. */ void loop() { /* * fade-down the backlight pin */ for (int i=255; i>=0; i--) { lcd.backLight(i); delay(10); } // pause a bit delay(200); /* * fade-up the backlight pin */ for (int i=0; i<255; i++) { lcd.backLight(i); delay(10); } delay(1000); }