#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Initialize the LCD. Change the I2C address if needed (default 0x27)
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Temperature sensor pins
const int sensorPin1 = A0;
const int sensorPin2 = A1;
const int sensorPin3 = A2;
// Function to convert analog value to temperature (assuming LM35 sensor)
float readTemperature(int sensorPin) {
int analogValue = analogRead(sensorPin);
// Convert the analog value to voltage
float voltage = analogValue * (5.0 / 1023.0);
// Convert voltage to temperature (LM35: 10mV per degree Celsius)
float temperature = voltage * 100.0;
return temperature;
}
void setup() {
// Initialize the LCD
lcd.begin(16, 2);
lcd.backlight(); // Turn on the backlight (if applicable)
R2=0;
}
void loop() {
// Read temperatures from the sensors
float temperature1 = readTemperature(sensorPin1);
float temperature2 = readTemperature(sensorPin2);
float temperature3 = readTemperature(sensorPin3);
// Clear the LCD
lcd.clear();
// Print temperatures to the LCD
R2 = temperature1 * (1023.0 / (temperature1) - 1.0);
lcd.setCursor(0, 0);
lcd.print("Temp 1: ");
lcd.print(R2);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Temp 2: ");
lcd.print(temperature2);
lcd.print(" C");
//lcd.setCursor(8, 2);
//lcd.print("Temp 3: ");
//lcd.print(temperature3);
//lcd.print(" C");
// Wait before the next update
delay(2000);
}