aide programme testeur de cable

bonjour
voila j’ai recuperé un programme de test de cable
il fonctionne sauf que si je fait une erreur de cablage ,il me met bien faux mais si je remet le contact bon et je relance alors il me met toujours faux
si je reinitialise l’arduino mega 2560 alors c’est bon

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal_I2C lcd(0x3f,20,4);
//pins
int endA[10] = {45,43,41,39,37,35,33,29,22,24}; //pins end A
int endB[10] = {44,42,40,38,36,34,32,28,31,26}; //pins endB
int pSwitch=49;

//results
int result[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int test[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int counter[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
bool fail =false;

void setup() {
lcd.init(); // initialize the lcd

lcd.backlight();

//setup pins
for(int i=0; i<10; i++){
pinMode(endA*, OUTPUT);//set output pins (end A)*
pinMode(endB*, INPUT_PULLUP);//set input pins (end B)
_
}_
pinMode(pSwitch,INPUT_PULLUP);
_
}_
void loop() {
_
//run the test*_
runTest_5x2();
}
void runTest_5x2(){
* String resultS="";*
* //user interface*
* lcd.clear();*
* lcd.print(“TESTEUR 10 FILS”);*
* lcd.setCursor(0,1);*
* lcd.print(“Appuie BP pour Start”);*

* while(digitalRead(pSwitch))*
* {*
* delay(100);*
* }*
* delay(500); //debounce*
* lcd.clear();*
* lcd.setCursor(0,0);*
* lcd.print(“MODE TEST”);*
* lcd.setCursor(0,1);*
* for(int i=0; i<10; i++){*
_ counter*=0;
for(int j=0; j<10; j++){
digitalWrite(endA, LOW); //set all outputs to LOW*

* }
for(int j=0; j<10; j++){ //check for crossed / open circuits vs closed, good, circuits*

* digitalWrite(endA[j], HIGH); //scan across the inputs in turn*
test = digitalRead(endB*); //read the output*
if(test == 1 && j!=i){ //crossed or open circuit
counter*++;
result = 20+j;
}
else if(test == 1 && j==i && result <20 ){ //Good, closed circuit
result = 0;
}
digitalWrite(endA[j],LOW);*_

* }*
* Serial.print("Core ");*
* Serial.print(i);*
* Serial.print(" result = ");*
_ if(result == 0){
* Serial.println(" 1");
resultS+=“1”;
}
else if(counter == 9){
Serial.println(" O");
resultS+=“0”;
fail=true;
}
else {
Serial.println(" X");
resultS+=“X”;
fail=true;
}
}*_

* lcd.print(resultS);*
* lcd.setCursor(0,2);*

if(fail){
* Serial.println("TEST FAUX ");*
* lcd.print(“TEST FAUX”);*
}
else{
* Serial.println(“TEST BON”);*
* lcd.print(“TEST BON”);*
}
Serial.println();
lcd.setCursor(0,3);
lcd.print(“Appuie BP pour Start”);
* while(digitalRead(pSwitch))*
* {*
* //delay(100);*

* }*
* //delay(500); //debounce*
}[/quote]
je ne sais pas d’ou vient l’erreur
cable_tester1.ino (2.46 KB)

affaire reglé j'ai deplacé

//results int result[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int test[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int counter[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; bool fail =false;

apres le

void loop() { //run the test runTest_5x2(); }

void runTest_5x2(){ String resultS=""; //results int result[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int test[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int counter[10] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; bool fail =false;