Pin probe

Hello Everyone :slight_smile:

I have made a previously a cable tester(code below) and now I was working on a Pin Probe Tester.

For the moment my pin probe tester works fine, but just for one type of cable, if i wish to probe another cable i need to reprogram the arduino. I was thinking if it is possible to use an sd card shield in order to import some variables from a txt file every time i want to change the program.

By variables, i wish to use an rotary encoder and an lcd to navigate the sd card and each time i want to test anoder cable i want just to put another txt file to sd card and select it from my lcd and this variable to change:

// --- Pins that are used for testing ---
int nod[19] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};

// --- Name of pins ---
String nume[]={ "1-Negru 8","2-Alb 9","3-Alb 10","4-Alb 11","5-Liber","6-Liber","7-Liber","8-Rosu 1","9-Rosu 2","10-Rosu 3","11-Rosu 4","12-Negru 5","13-Negru 6","14-Negru 7","15 Portocaliu","16 Alb-Albastru","17 Alb-Portocaliu","18 Albastru"};

This is my code so far:

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

#define I2C_ADDR    0x27 // Add your address here.  Find it from I2C Scanner
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

LiquidCrystal_I2C  lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);

int probe = 3; //probe
int buzz = 2; //buzzer
int mode = 1; // set the mode

// --- Pins that are used for testing ---
int nod[19] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};

// --- Name of pins ---
String nume[]={ "1-Negru 8","2-Alb 9","3-Alb 10","4-Alb 11","5-Liber","6-Liber","7-Liber","8-Rosu 1","9-Rosu 2","10-Rosu 3","11-Rosu 4","12-Negru 5","13-Negru 6","14-Negru 7","15 Portocaliu","16 Alb-Albastru","17 Alb-Portocaliu","18 Albastru"};
   
int lennume=sizeof(nume) / sizeof(nume[0]); 


void setup() {
 
 MCUSR = 0;  // clear out any flags of prior resets.
 lcd.begin (16, 2); // LCD type 16x2

 // Switch on the backlight
 lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
 lcd.setBacklight(HIGH);
 lcd.home (); // go home

 //setup pins I/O
 for (int i = 0; i < lennume+1; i++){
 pinMode(nod[i], INPUT_PULLUP);  //set all pins as input_pullup
 }
 
 pinMode(probe, OUTPUT); //set probe output
  pinMode(buzz, OUTPUT); //buzzer

}

void loop() {

  lcd.clear();
  lcd.print("Pin Probe"); //main title 1st row
  lcd.setCursor(0, 1);
  lcd.print(""); //main title 2nd row

  delay(4500);

    

  //Probe
  mode = 1;     
  while (mode == 1) {
      
    //LCD interface 
    lcd.clear();
    lcd.print("   Probe mode"); //main title
    lcd.setCursor(0, 1);
    lcd.print("Pin:");
    lcd.setCursor(4, 1);
    
    for (int i = 0 ; i < lennume+1; i++) {  //check all pins one by one
        
        //reads the output on the pin and if there is a connection with the probe => i = 0 and displays a message, otherwise i remains = 1
        if( digitalRead(nod[i])==0){
            lcd.print((String) nume[i]);
            
            digitalWrite(buzz, HIGH);
            delay(150);
            digitalWrite(buzz, LOW);
            delay(150);          
            
         }
     }
     
 delay(100);
  }
}

Does anyone want to help me do this project ?

Cable tester Code:

#include <avr/wdt.h> //autoreset
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x3F // <<----- Add your address here.  Find it from I2C Scanner
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

int n = 1;
int data;
LiquidCrystal_I2C  lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
//pins
int ledPinFail = 2;
int endA[5] = {3, 4, 5, 6, 7}; //pins end A
int endB[5] = {8, 9, 10, 11, 12}; //pins endB
int pSwitch = 13;

//results
int result[5] = { -1, -1, -1, -1, -1};
int test[5] = { -1, -1, -1, -1, -1};
int counter[5] = { -1, -1, -1, -1, -1};
bool fail = false;
int nume = -1;  //local variable for probe
int nume2 = - 1; //local variable for probe
int mode = -1; // set the mode


void setup() {

  MCUSR = 0;  // clear out any flags of prior resets.
  Serial.begin(115200); //serial used for debugging only
  lcd.begin (16, 2); //  <<----- My LCD was 16x2


  // Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.setBacklight(HIGH);
  lcd.home (); // go home

  //setup pins
  for (int i = 0; i < 5; i++) {
    pinMode(endA[i], OUTPUT);//set output pins (end A)                 
    pinMode(endB[i], 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(" USB Tester "); //main title
  lcd.setCursor(0, 1);
  lcd.print(""); //main2 title

  delay(1500);
while (digitalRead(pSwitch)) //buton start #Nu-l sterge!!!
  
  delay(200); //debounce
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Testing Cable..."); //under test message
  delay(750);

  for (int i = 0; i < 5; i++) {
    counter[i] = 0;
    for (int j = 0; j < 5; j++) {
      digitalWrite(endA[i], LOW); //set all outputs to LOW
    }
    for (int j = 0; j < 6; j++) { //check for crossed / open circuits vs closed, good, circuits
      digitalWrite(endA[j], HIGH); //scan across the inputs in turn
      test[i] = digitalRead(endB[i]); //read the output
      if (test[i] == 1 && j != i) { //crossed or open circuit
        counter[i]++;
        result[i] = 10 + j;
      }
      else if (test[i] == 1 && j == i && result[i] < 10 ) { //Good, closed circuit
        result[i] = 0;
      }
      digitalWrite(endA[j], LOW);
    }

    delay(50); //delay intre teste
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Testing pins");
    lcd.print(i + 1);
    if (result[i] == 0) {
      lcd.print("");
      resultS += "1";
      pinMode(ledPinFail, OUTPUT);
      digitalWrite(ledPinFail, HIGH);
      delay(25);
      digitalWrite(ledPinFail, LOW);
      delay(25);
    }
    else if (counter[i] == 5) {
      lcd.setCursor(0, 1);
      lcd.print("Open grup ");
      lcd.print(i + 1);
      pinMode(ledPinFail, OUTPUT);
      digitalWrite(ledPinFail, HIGH);
      delay(250);
      digitalWrite(ledPinFail, LOW);
      delay(250);
      fail = true;

    }

    else {
      lcd.setCursor(0, 1);
      lcd.print("Short/Cross ");
      lcd.print(i + 1);
      pinMode(ledPinFail, OUTPUT);
      digitalWrite(ledPinFail, HIGH);
      delay(250);
      digitalWrite(ledPinFail, LOW);
      delay(250);
      fail = true;
    }
  }

  lcd.setCursor(0, 0);
  delay(1000);
  if (fail) {
    lcd.clear();
    lcd.print("Bad Cable"); //Fail cable

    //buzzer
/*
    pinMode(ledPinFail, OUTPUT);
    digitalWrite(ledPinFail, HIGH);
    delay(1000);
 */
  }
  else {
    Serial.println();
    lcd.clear();
    lcd.print("OK Cable"); //OK cable
    lcd.setCursor(0, 2);
    lcd.print("Auto Reset");
  }
  
  delay(70); //debounce
  wdt_enable(WDTO_15MS); // turn on the WatchDog and don't stroke it.
  for (;;) {

  }
}