//#include <Wire.h>
//#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 13
//LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address
LiquidCrystal_I2C lcd(0x27,20,4);
//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address
char line0[21];
char line1[21];
char line2[21];
char line3[21];
// Creat a set of new characters
const uint8_t charBitmap[][8] = {
{ 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
{ 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
{ 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
{ 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
{ 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
{ 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
{ 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
{ 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
};
void setup()
{
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
// Switch on the backlight
pinMode ( BACKLIGHT_PIN, OUTPUT );
digitalWrite ( BACKLIGHT_PIN, HIGH );
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("SumpPump Monitor");
lcd.setCursor(2,1);
lcd.print("Version 1.0");
lcd.setCursor(0,2);
lcd.print("PrimaryPump:");
lcd.setCursor(2,3);
lcd.print("BackupPump:");
delay(2000);
}
/*
lcd.begin(16,2); // initialize the lcd
for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap[i] );
}
lcd.home (); // go home
lcd.print("Hello, ARDUINO ");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print (" FORUM - fm ");
delay ( 1000 );
}
*/
void loop()
{
line0[4] = 8;
line0[5] = 5;
line0[6] = "C";
updateDisplay();
/*
// Buffer for float
char float_str[8];
char line0[21];
float temperature = 15.12;
dtostrf(temperature,4,2,float_str);
*/
// Now you can sprintf
//sprintf(line0, "Temp: %-7sC", float_str); // %6s right pads the string
/*
float vinMtr = (analogRead(A0) * (5.0 / 1023.0)); // * 9.99;
lcd.clear();
lcd.print("Battery Volts:");
lcd.setCursor(0,1);
lcd.print(vinMtr);
delay(2000);
*/
/*
lcd.home ();
// Do a little animation by writing to the same location
for ( int i = 0; i < 2; i++ )
{
for ( int j = 0; j < 16; j++ )
{
lcd.print (char(random(7)));
}
lcd.setCursor ( 0, 1 );
}
delay (200);
*/
}
void updateDisplay() {
lcd.setCursor(0,0);
lcd.print(line0);
lcd.print(line1);
lcd.print(line2);
lcd.print(line3);
delay(2000);
}