Compteur millis() Besoin d'aide programmation

Oui, mais le soucis est que si un des pieds a coulisses s'éteint, les autres ne fonctionnent plus ! (faut bien dire que j'ai fais du bricolage !!)

Voici mon code

  while (digitalRead(clockpinX)==HIGH) {} //if clock is LOW wait until it turns to HIGH
  tempmicrosX=micros();
  while (digitalRead(clockpinX)==LOW) {} //wait for the end of the HIGH pulse
  if ((micros()-tempmicrosX)>500) { //if the HIGH pulse was longer than 500 micros we are at the start of a new bit sequence
    decodeX(); //decode the bit sequence
  }

  while (digitalRead(clockpinY)==HIGH) {} //if clock is LOW wait until it turns to HIGH
  tempmicrosY=micros();
  while (digitalRead(clockpinY)==LOW) {} //wait for the end of the HIGH pulse
  if ((micros()-tempmicrosY)>500) { //if the HIGH pulse was longer than 500 micros we are at the start of a new bit sequence
    decodeY(); //decode the bit sequence
  }
  
  while (digitalRead(clockpinZ)==HIGH) {} //if clock is LOW wait until it turns to HIGH
  tempmicrosZ=micros();
  while (digitalRead(clockpinZ)==LOW) {} //wait for the end of the HIGH pulse
  if ((micros()-tempmicrosZ)>500) { //if the HIGH pulse was longer than 500 micros we are at the start of a new bit sequence
    decodeZ(); //decode the bit sequence
  }
}

//=======================================================================================================//
void decodeX() {
  signX=1;
  valueX=0;
  for (iX=0;iX<23;iX++) {
    while (digitalRead(clockpinX)==HIGH) { } //wait until clock returns to HIGH- the first bit is not needed
    while (digitalRead(clockpinX)==LOW) {} //wait until clock returns to LOW
    if (digitalRead(datapinX)==LOW) {
      if (iX<20) {
        valueX|= 1<<iX;
      }
      if (iX==20) {
        signX=-1;
      }
    }
  }
  
  resultX=(valueX*signX)/100.00;
  
            lcd.setCursor(0, 1);         
            lcd.print ("X:        ");
            lcd.setCursor(2, 1);         
            lcd.print (resultX,2);
            
   delay(5);
            
  }

//==================================================================================================//

void decodeY() {
  signY=1;
  valueY=0;
  for (iY=0;iY<23;iY++) {
    while (digitalRead(clockpinY)==HIGH) { } //wait until clock returns to HIGH- the first bit is not needed
    while (digitalRead(clockpinY)==LOW) {} //wait until clock returns to LOW
    if (digitalRead(datapinY)==LOW) {
      if (iY<20) {
        valueY|= 1<<iY;
      }
      if (iY==20) {
        signY=-1;
      }
    }
  }
 
  resultY=(valueY*signY)/100.00;
  
            lcd.setCursor(0, 2);         
            lcd.print ("Y:        ");
            lcd.setCursor(2, 2);         
            lcd.print (resultY,2);

  delay(5);            
           
 }           

//================================================================================================//

void decodeZ() {
  signZ=1;
  valueZ=0;
  for (iZ=0;iZ<23;iZ++) {
    while (digitalRead(clockpinZ)==HIGH) { } //wait until clock returns to HIGH- the first bit is not needed
    while (digitalRead(clockpinZ)==LOW) {} //wait until clock returns to LOW
    if (digitalRead(datapinZ)==LOW) {
      if (iZ<20) {
        valueZ|= 1<<iZ;
      }
      if (iZ==20) {
        signZ=-1;
      }
    }
  }
  
            resultZ=(valueZ*signZ)/100.00;

            lcd.setCursor(0, 3);         
            lcd.print ("Z:        "); 
            lcd.setCursor(2, 3);         
            lcd.print (resultZ,2);

  delay(5);

}