const float ADC_VREF_V = 5.0; // Tension de référence de l'ADC en volts (5 V)
const int ADC_RESOLUTION = 4095; // Résolution de l'ADC (2^12 - 1)
const int LM35 = 15;
const byte pinRed = 2; // Pin connected to the red LED
const byte pinJaune = 4; // Pin connected to the red LED
void setup()
{
pinMode(LM35, INPUT);
pinMode(pinRed, OUTPUT); // Set the red LED pin as an output
Serial.begin(115200);
digitalWrite(pinRed, LOW);
digitalWrite(pinJaune, LOW);
}
void loop() {
int ADC;
float temp;
ADC = analogRead(LM35);
// Calculer la tension en volts
float voltage = ADC * (ADC_VREF_V / ADC_RESOLUTION);
// Calculer la température en degrés Celsius
temp = voltage * 100.0;
Serial.print("Tension = ");
Serial.print(voltage);
Serial.println(" V");
Serial.print("Température = ");
Serial.print(temp);
Serial.println(" °C");
if (temp >= 3.0) {
digitalWrite(pinRed, HIGH);
digitalWrite(pinJaune, LOW);
}else{
digitalWrite(pinRed, LOW);
digitalWrite(pinJaune, HIGH);
}
delay(1000);
}