Thank you for all. I have this code:
Depend the initial test connected, the system choice a CASE, this case, in the CASE 1, and in the CASE 1, follow the setup the pin need to change, but the system see just the first setup pin, in out the CASE 1 permanent, how can I do this?
Undestanding:
First a test in pin MA output, depend the result 1 or 0 in other pin, the system do another test, but need to change the pinmode, You understood my idea?
if (botao_estado == 1) {
pinMode(MA, OUTPUT);
pinMode(BM, INPUT_PULLUP);
pinMode(LA, INPUT_PULLUP);
pinMode(BL, INPUT_PULLUP);
pinMode(BA, INPUT_PULLUP);
pinMode(VD, INPUT_PULLUP);
pinMode(BV, INPUT_PULLUP);
int stat_BM = digitalRead(BM);
int stat_BL = digitalRead(BL);
int stat_BA = digitalRead(BA);
int stat_BV = digitalRead(BV);
int stat_LA = digitalRead(LA);
int stat_VD = digitalRead(VD);
if (stat_BM <= 0) {
PADCAB = '1';
}
else if (stat_BL <= 0) {
PADCAB = '2';
}
else if (stat_BA <= 0) {
PADCAB = '3';
}
else if (stat_BV <= 0) {
PADCAB = '4';
}
else if (stat_LA <= 0) {
PADCAB = '5';
}
else if (stat_VD <= 0) {
PADCAB = '6';
}
else {
PADCAB = 'X';
Serial.println("ERRO: Cabo nao conectado, verifique!");
}
}
//PAC+CAB Padrao do cabo A ou B / CAB 1, 2, 3, 4, 5 ou 6
switch (PADCAB) {
case '1':
Serial.println("Testando Cabo 1");
pinMode(MA, OUTPUT);
pinMode(BM, INPUT_PULLUP);
pinMode(LA, OUTPUT);
pinMode(BL, INPUT_PULLUP);
pinMode(AZ, OUTPUT);
pinMode(BA, INPUT_PULLUP);
pinMode(VD, OUTPUT);
pinMode(BV, INPUT_PULLUP);
int stat_BM = digitalRead(BM);//0
int stat_BL = digitalRead(BL);//1
int stat_BA = digitalRead(BA);//0
int stat_BV = digitalRead(BV);//1
Serial.println(digitalRead(BM));
Serial.println(digitalRead(BL));
Serial.println(digitalRead(BA));
Serial.println(digitalRead(BV));
if (stat_BM == 0 && stat_BL == 0 && stat_BA == 0 && stat_BV == 0) {
Serial.println("Cabo 1 - OK!");
}
else {
Serial.println("Cabo 1 - ERRO!");
}
break;