Lire deux capteur d'humidité a intervalle différent non bloquant.

Oui les if et pas les int dsl.

Voici le code actuel :

const int canal = 10; // niveau d'eau canal
const int pompe = 9; // relais pompe
const int capthumidite = 8; // détecteur d'humidité numéro 1
int ledhumide = 7;
int ledsec = 6;
int ledniveaucanalbas = 5;
int ledniveaucanalhaut = 4;
const int ledprogramateur = 3;
int pumpLEDPin = 2; // Led  pompe verte

// Time periods  in milliseconds (1000 to a second).
const unsigned long canalinterval = 3000;
const unsigned long capthumiditeinterval = 180000;

// Variable holding the timer value so far. One for each "Timer"
unsigned long canaltimer;
unsigned long capthumiditetimer;

int niveaucanal; // état du du niveau d'eau canal
int humidite; // état du détecteur 1


void setup ()
{
  // Configure la broche avec la résistance de tirage
  Serial.begin(9600);
  pinMode (canal, INPUT); // entrée capteur niveau canal
  pinMode (capthumidite, INPUT); // entrée capteur sol humidité
  pinMode(pompe, OUTPUT); // pompe est une broche de sortie
  pinMode(ledhumide, OUTPUT);
  pinMode(ledsec, OUTPUT);
  pinMode(ledniveaucanalbas, OUTPUT);
  pinMode(ledniveaucanalhaut, OUTPUT);
  pinMode(ledprogramateur, OUTPUT);
  pinMode(pumpLEDPin, OUTPUT);

  int humidite = digitalRead(capthumidite); // Lecture de l etat du détecteur 1
  int niveaucanal = digitalRead(canal); // Lecture de l etat du du niveau d'eau canal



  canaltimer = millis ();
  capthumiditetimer = millis ();




}  // end of setup

void togglecanal ()
{

  niveaucanal = digitalRead(canal); // Lecture de l etat du du niveau d'eau canal

  // remember when we toggled it
  canaltimer = millis ();

  Serial.print(millis());
}  // end of togglecanal

void togglecapthumidite ()
{


  humidite = digitalRead(capthumidite); // Lecture de l etat du détecteur 1


  // remember when we toggled it
  capthumiditetimer = millis ();

  Serial.print(millis());
}  // end of togglecapthumidite

void loop ()
{

  // Handling the blink of one sensor
  if ( (millis () - canaltimer) >= canalinterval)
    togglecanal ();

  // The other sensor is controlled the same way. Repeat for more sensors
  if ( (millis () - capthumiditetimer) >= capthumiditeinterval)
    togglecapthumidite ();

  /* Other code that needs to execute goes here.
     It will be called many thousand times per second because the above code
     does not wait for the sensor blink interval to finish. */


  digitalWrite(ledprogramateur, HIGH); // Allumer Led programateur








  if  (humidite == LOW) {
    digitalWrite(ledhumide, HIGH); // Allumer LED humide
    digitalWrite(ledsec, LOW); // Eteindre Led sec
  }

  if  (humidite == HIGH) {
    digitalWrite(ledsec, HIGH); // Allumer Led sec
    digitalWrite(ledhumide, LOW); // Eteindre LED humide
  }

  if  ((niveaucanal) == HIGH) {
    digitalWrite(ledniveaucanalbas, HIGH); // Allumer LED niveau canal bas
    digitalWrite(ledniveaucanalhaut, LOW); // Eteindre Led niveau canal haut
  }

  if  ((niveaucanal) == LOW) {
    digitalWrite(ledniveaucanalbas, LOW); // Eteindre Led niveau canal bas
    digitalWrite(ledniveaucanalhaut, HIGH); // Allumer LED niveau canal haut
  }






  // Agir en fonction de l'état des parametres
  if ((humidite == HIGH) && (niveaucanal == LOW))
  {
    digitalWrite(pompe, LOW);
    digitalWrite(pumpLEDPin, HIGH); // Allumer Led pompe
  }
  else
  {
    digitalWrite(pompe, HIGH);
    digitalWrite(pumpLEDPin, LOW); // Eteindre Led pompe
  }




  delay(3000); // Attendre 3 seconde (prendre des mesures toutes les 3 secondes)




}  // end of loop