#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(32,16,2);
void setup()
{
lcd.begin(16,2);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temperature: ");
}
void loop()
{
// Read the temperature from the sensor
int sensorValue = analogRead(A0);
// Convert the temperature to degrees Celsius
float temperature = (sensorValue * 5.0 / 1024.0 - 0.5 ) * 100.0; // convert the sensor value to temperature in degrees Celsius
// Display the temperature on the LCD
lcd.setCursor(8, 1);
lcd.print(temperature);
lcd.print(" C");
}
No comments:
Post a Comment