On peut utiliser 2 boutons, mais c'est possible avec un seul, essaye avec ca :
int TMP36 = 1;
int brocheBouton = 2;
int etatBouton;
int etat = 0;
void setup() {
Serial.begin(19200);
pinMode(brocheBouton, INPUT);
}
void loop(){
etatBouton = digitalRead(brocheBouton);
int lecture = analogRead(TMP36);
float voltage = lecture * 5.0;
voltage /= 1024.0; // float voltage * 5 Volt / 1024 echellons
Serial.print(voltage); Serial.println(" Volts");
if(etatBouton == HIGH){
if(etat <= 0) {
etat++;
}
if(etat >= 1) {
etat--;
}
}
if(etat == 1){
float temperatureCelsius = (voltage - 0.5) * 100 ;
Serial.print(temperatureCelsius); Serial.print(" degres C ");
delay(300);
}
if (etat == 0){
float temperatureFarenheit = (((voltage - 0.5)* 100)*1.8)+ 32.0;
Serial.print(temperatureFarenheit); Serial.println(" degres F");
delay(300);
}
}