Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By tele_player
#74157 Here is a simple solution:

Code: Select all#include <Arduino.h>

typedef enum {
  S, // SECURITE
  N, // NUIT
  J1_1, J1_2, J1_3,  // Luminosité 1
  J2_1, J2_2, J2_3,  // Luminosité 2
  J3_1, J3_2, J3_3, // Luminosité 3
} STATES;

STATES CYCLE_ARROSAGE; // SECURITE

void setup () {
  CYCLE_ARROSAGE = N; // OK

}

void loop () {
  CheckChangementCycleArrosage(J2_2);
}

void CheckChangementCycleArrosage(STATES NouveauCycle ){

  if(CYCLE_ARROSAGE != NouveauCycle){
   
    Serial.print("CYCLE CHECKE : ");
    Serial.println(NouveauCycle); // -> 6
   
    Serial.print("CYCLE CHECKE CAST: ");
    Serial.println(String(NouveauCycle)); // -> 6
   
    Serial.print("CYCLE ARROSAGE: ");
    Serial.println(CYCLE_ARROSAGE); // -> 1
     
    CYCLE_ARROSAGE = NouveauCycle; // WAS error, now OK
 
  }
}