hello, I have a problem in my programming, the thing is, I am making a tester of different cables with their respective pins, I have different connectors ready to be connected to test each cable, this project has a menu to make it more intuitive, Getting to the point, the problem is that I am giving 5 volts to the output and reading the input to see if there is continuity, I would like to know how to differentiate between the pins, sorry I am new to this, thanks in advance. (I leave the program).
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
int upButton = 11;
int downButton = 12;
int selectButton = 13;
int menu = 1;
//SINGLE
const int pin1entradasingle= {9};
const int pin1salidasingle= {4};
const int pin2entradasingle= {8};
const int pin2salidasingle= {3};
const int pin3entradasingle= {7};
const int pin3salidasingle= {2};
const int pin4entradasingle= {6};
const int pin4salidasingle= {1};
const int pin5entradasingle= {5};
const int pin5salidasingle= {0};
//STRIKE
const int pin1entradastrike= {34};
const int pin1salidastrike= {35};
const int pin2entradastrike= {36};
const int pin2salidastrike= {37};
const int pin3entradastrike= {38};
const int pin3salidastrike= {39};
const int pin4entradastrike= {40};
const int pin4salidastrike= {41};
const int pin5entradastrike= {42};
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
//single
pinMode(pin1entradasingle,INPUT_PULLUP);
pinMode(pin1salidasingle,OUTPUT);
pinMode(pin2entradasingle,INPUT_PULLUP);
pinMode(pin2salidasingle,OUTPUT);
pinMode(pin3entradasingle,INPUT_PULLUP);
pinMode(pin3salidasingle,OUTPUT);
pinMode(pin4entradasingle,INPUT_PULLUP);
pinMode(pin4salidasingle,OUTPUT);
pinMode(pin5entradasingle,INPUT_PULLUP);
pinMode(pin5salidasingle,OUTPUT);
//strike
pinMode(pin1entradastrike,INPUT_PULLUP);
pinMode(pin1salidastrike,OUTPUT);
pinMode(pin2entradastrike,INPUT_PULLUP);
pinMode(pin2salidastrike,OUTPUT);
pinMode(pin3entradastrike,INPUT_PULLUP);
pinMode(pin3salidastrike,OUTPUT);
pinMode(pin4entradastrike,INPUT_PULLUP);
pinMode(pin4salidastrike,OUTPUT);
pinMode(pin5entradastrike,INPUT_PULLUP);
pinMode(upButton, INPUT_PULLUP);
pinMode(downButton, INPUT_PULLUP);
pinMode(selectButton, INPUT_PULLUP);
//(Portada Cable Tester EBengineering)
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Multi-Cable");
lcd.setCursor(0,1);
lcd.print(" Continuity Tester");
lcd.setCursor(0,2);
lcd.print(" Creado por:");
lcd.setCursor(0,3);
lcd.print(" EBengineering");
delay(4000);
updateMenu();
}
void loop() {
if (!digitalRead(downButton)){
menu++;
updateMenu();
delay(100);
while (!digitalRead(downButton));
}
if (!digitalRead(upButton)){
menu--;
updateMenu();
delay(100);
while(!digitalRead(upButton));
}
if (!digitalRead(selectButton)){
executeAction();
updateMenu();
delay(100);
while (!digitalRead(selectButton));
}
}
void updateMenu() {
switch (menu) {
case 0:
menu = 1;
break;
case 1:
lcd.clear();
lcd.print(">Single");
lcd.setCursor(0, 1);
lcd.print(" Strike");
lcd.setCursor(0,2);
lcd.print(" Gasolina");
lcd.setCursor(0,3);
lcd.print(" MenuItem4");
break;
case 2:
lcd.clear();
lcd.print(" Single");
lcd.setCursor(0, 1);
lcd.print(">Strike");
lcd.setCursor(0,2);
lcd.print(" Gasolina");
lcd.setCursor(0,3);
lcd.print(" MenuItem4");
break;
case 3:
lcd.clear();
lcd.print(" Single");
lcd.setCursor(0, 1);
lcd.print(" Strike");
lcd.setCursor(0,2);
lcd.print(">Gasolina");
lcd.setCursor(0,3);
lcd.print(" MenuItem4");
break;
case 4:
lcd.clear();
lcd.print(" Single");
lcd.setCursor(0, 1);
lcd.print(" Strike");
lcd.setCursor(0,2);
lcd.print(" Gasolina");
lcd.setCursor(0,3);
lcd.print(">MenuItem4");
break;
case 5:
lcd.clear();
lcd.print(">MenuItem5");
lcd.setCursor(0,1);
lcd.print(" MenuItem6");
break;
case 6:
lcd.clear();
lcd.print(" MenuItem5");
lcd.setCursor(0,1);
lcd.print(">MenuItem6");
break;
menu = 6;
break;
}
}
void executeAction() {
switch (menu) {
case 1:
single();
break;
case 2:
strike();
break;
case 3:
gasolina();
break;
case 4:
action4();
case 5:
action5();
case 6:
action6();
break;
}
}
void single() {
lcd.clear();
lcd.print(">Executing...");
delay(1500);
lcd.clear();
// principio single
//pin1
digitalWrite(pin1salidasingle, HIGH);
if(digitalRead(pin1entradasingle) == HIGH) {
lcd.setCursor(0,0);
lcd.print("P1-4:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin1entradasingle) == LOW) ;
lcd.setCursor(0,0);
lcd.print("P1-4:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//pin2
digitalWrite(pin2salidasingle, HIGH);
if(digitalRead(pin2entradasingle) == HIGH) {
lcd.setCursor(10,0);
lcd.print("P2-1:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin2entradasingle) == LOW) ;
lcd.setCursor(10,0);
lcd.print("P2-1:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//pin3
digitalWrite(pin3salidasingle, HIGH);
if(digitalRead(pin3entradasingle) == HIGH) {
lcd.setCursor(0,1);
lcd.print("P3-2:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin3entradasingle) == LOW) ;
lcd.setCursor(0,1);
lcd.print("P3-2:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//pin4
digitalWrite(pin4salidasingle, HIGH);
if(digitalRead(pin4entradasingle) == HIGH) {
lcd.setCursor(10,1);
lcd.print("P5-5:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin4entradasingle) == LOW) ;
lcd.setCursor(10,1);
lcd.print("P5-5:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//pin5
digitalWrite(pin5salidasingle, HIGH);
if(digitalRead(pin5entradasingle) == HIGH) {
lcd.setCursor(0,2);
lcd.print("P6-3:OK");
digitalWrite(LED_BUILTIN, HIGH);
delay(10000);
}else{(digitalRead(pin5entradasingle) == LOW) ;
lcd.setCursor(0,2);
lcd.print("P6-3:X");
digitalWrite(LED_BUILTIN, HIGH);
delay(10000);}
}
//fin single
void strike() {
lcd.clear();
lcd.print(">Executing...");
delay(1500);
lcd.clear();
//principio strike
//pin1
digitalWrite(pin1salidastrike, HIGH);
if(digitalRead(pin1entradastrike) == HIGH) {
lcd.setCursor(0,0);
lcd.print("C1-1:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin1entradastrike) == LOW) ;
lcd.setCursor(0,0);
lcd.print("C1-1:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//pin2
digitalWrite(pin2salidastrike, HIGH);
if(digitalRead(pin2entradastrike) == HIGH) {
lcd.setCursor(10,0);
lcd.print("C2-2:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin2entradastrike) == LOW) ;
lcd.setCursor(10,0);
lcd.print("C2-2:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//pin3
digitalWrite(pin3salidastrike, HIGH);
if(digitalRead(pin3entradastrike) == HIGH) {
lcd.setCursor(0,1);
lcd.print("C3-3:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin3entradastrike) == LOW) ;
lcd.setCursor(0,1);
lcd.print("C3-3:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//pin4
digitalWrite(pin4salidastrike, HIGH);
if(digitalRead(pin4entradastrike) == HIGH) {
lcd.setCursor(10,1);
lcd.print("C4-4:OK");
digitalWrite(LED_BUILTIN, HIGH);
}else{(digitalRead(pin4entradastrike) == LOW) ;
lcd.setCursor(10,1);
lcd.print("C4-4:X");
digitalWrite(LED_BUILTIN, HIGH);
}
//PUENTE C5
digitalWrite(pin4salidastrike, HIGH);
if(digitalRead(pin5entradastrike) == HIGH) {
lcd.setCursor(0,2);
lcd.print("PUENTE C5-4:OK");
digitalWrite(LED_BUILTIN, HIGH);
delay(100000);
}else{(digitalRead(pin5entradastrike) == LOW) ;
lcd.setCursor(0,2);
lcd.print("PUENTE C5-4:X");
digitalWrite(LED_BUILTIN, HIGH);
delay(100000);
}
//fin STRIKE
}
void gasolina() {
lcd.clear();
lcd.print(">Executing...");
delay(1500);
lcd.clear();
}
void action4() {
lcd.clear();
lcd.print(">Executing...");
delay(1500);
lcd.clear();
}
void action5() {
lcd.clear();
lcd.print(">Executing...");
delay(1500);
lcd.clear();
}
void action6() {
lcd.clear();
lcd.print(">Executing...");
delay(1500);
lcd.clear();
}