// Pin assignments
const int POTENTIOMETER_PIN = A1;
const int TEMPERATURE_SENSOR_PIN = A0;
const int RELAY_PIN = 2;
void setup() {
Serial.begin(9600);
pinMode(RELAY_PIN, OUTPUT);
}
void loop() {
// Read potentiometer value
int potentiometerValue = analogRead(POTENTIOMETER_PIN);
float voltage = potentiometerValue;
Serial.print("Potentiometer Voltage: ");
Serial.println(voltage);
// Read temperature sensor value
int temperatureSensorValue = analogRead(TEMPERATURE_SENSOR_PIN);
float temperature = 1.0 / (log(1.0 / (1023.0 / temperatureSensorValue - 1.0)) / 3950.0 + 1.0 / (298.15 + voltage)) - 273.15;
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" degrees Celsius");
// Control relay based on potentiometer value
if (voltage > 50) {
digitalWrite(RELAY_PIN, HIGH); // Turn on relay
} else {
digitalWrite(RELAY_PIN, LOW); // Turn off relay
}
delay(1000);
}