// C++ code
//
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int baselineTemp = 0;
int celsius = 0;
int fahrenheit = 0;
LiquidCrystal_I2C lcd( 0x27, 16, 2);
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
Serial.begin(115200);
while (!Serial) // wait for serial port to connect. Needed for native USB
{
delay(10);
}
Serial.println( "The sketch has started.");
Wire.begin(); // use the default, GPIO4 = SDA, GPIO5 = SCL
Serial.print( "Scanning for I2C addresses: ");
Serial.println( "Ready.");
// Initial text on the first display
lcd.init();
lcd.backlight(); // turn on backlight
lcd.setCursor( 0, 0);
lcd.print( "It is working");
lcd.setCursor( 0, 1);
}
void loop()
{
// set threshold temperature to activate LEDs
baselineTemp = 40;
// measure temperature in Celsius
celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125);
// convert to Fahrenheit
fahrenheit = ((celsius * 9) / 5 + 32);
Serial.println(celsius);
Serial.println(" C, ");
Serial.println(fahrenheit);
Serial.println(" F");
delay(1000); // Wait for 1000 millisecond(s)
}