david_prentice:
I don't believe you.
That's fine. But it is a fact.
I have two dozen happy customers with units with this code installed:
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
// DEBUG_MODE
// 1 ADC Readings
// 2 Temp reading timer
// 4 DAC
#define DEBUG_MODE 4
#define TEMP_READ_INTERVAL 250 // enter interval in milliseconds
#define SP_DISPLAY_TIME 5000 // enter interval in milliseconds
#define ALM_ACK 2
#define ALM_LIGHT 12
#define ALM_BUZZER 11
#define TEMP_PIN 2
#define OFF_SP_PIN 1
#define ON_SP_PIN 3
#define SP_Offset 100.0 //degF
#define SP_Sens 100.0 / 5.0 //100 degF span over 5.0 volts
#define temp_amp_gain 2.0
#define on_amp_gain 1.0
#define off_amp_gain 1.0
#define adc_sens 1.0*5.0/1024.0 // voltage value of one ADC step
LiquidCrystal_I2C lcd(0x27);
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
byte adc_pin = 0;
int adcReading;
boolean adcStarted=false;
boolean adcDone=false;
float on_temp_sp, off_temp_sp, temp_reading;
byte Startup_Complete =0;
boolean alarm_status = 0;
boolean alarm_ack = 0;
// ADC complete ISR
ISR (ADC_vect)
{
byte low, high;
low = ADCL;
high = ADCH;
adcReading = (high << 8) | low;
adcDone = true;
} // end of ADC_vect
void setup()
{
lcd.begin(16, 2);
Serial.begin (115200);
pinMode(ALM_ACK, INPUT);
pinMode(ALM_BUZZER, OUTPUT);
pinMode(ALM_LIGHT, OUTPUT);
Startup_Complete=0;
alarm_ack=0;
digitalWrite(ALM_BUZZER, 0);
digitalWrite(ALM_LIGHT, 0);
adc_pin = TEMP_PIN;
Wire.begin();
}
Please feel free to explain how it works.
(only the relevant part posted as the whole program exceeds the 9k limit)
Edit:
Here is the code from the HelloWorld_I2C included with fmalpartida NewLiquidCrystal library:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 13
LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address
//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address
// 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.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()
{
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);
}
Two items to note:
- The constructor is LiquidCrystal_I2C lcd(0x38);
- It doesn't work either without modifying the constructor. It used to work, I used it and the I2CLCDGuesser to test each LCD when it arrives.