void setup() {
Serial.begin(115200);
pinMode(22, OUTPUT);
analogReadResolution(10);
}
void loop() {
int adcRaw = analogRead(26);
float mV = (adcRaw * 3300.0) / 1023.0; // Usa 5000.0 se alimenti a 5V
if (mV>=1000) { //1000mV
digitalWrite(22,HIGH);
} else {
digitalWrite(22,LOW);
}
// convert the Celsius to Fahrenheit
float tempC = mV / 10;
float tempF = tempC * 9 / 5 + 32;
// Serial Monitor:
Serial.print("Valore in mV: ");
Serial.println(mV);
Serial.print("Temperatura: ");
Serial.print(tempC); // temperatura in gradi Celsius
Serial.print("°C");
Serial.print(" ~ ");
Serial.print(tempF); // temperatura in gradi Fahrenheit
Serial.println("°F");
delay(500);
}