MorganS:
Is Google broken today? This kind of request is very common. I'm surprised you can't find some examples online. I will advise you to stay away from Instructables. Those projects are universally useless. But they can give you some good ideas to pursue.
What is your programming experience?
Do you have additional 19-pin connectors so that you can easily plug the cable-under-test into your tester?
My experience in programming is very basic, i have the male and the female connectors of the cable that i need to test, i can wire it directly but i need a program.
So far i come up with this code, but nothing works...
//LCD
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h> // F Malpartida's NewLiquidCrystal library
#define I2C_ADDR 0x27 // Define I2C Address for controller
#define BACKLIGHT_PIN 7
#define En_pin 4
#define Rw_pin 5
#define Rs_pin 6
#define D4_pin 0
#define D5_pin 1
#define D6_pin 2
#define D7_pin 3
#define LED_OFF 0
#define LED_ON 1
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
int endA[10] = {30,31,28,29,26,27,24,25,22,23}; //pins end A
int endB[10] = {41,43,38,39,36,37,34,35,32,33}; //pins endB
int pSwitch= 49;
int pEncA= 59;
int pEncB= 63;
//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() {
Serial.begin(115200); //serial used for debugging only
lcd.begin(16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,NEGATIVE);
lcd.setBacklight(LED_ON);
//setup pins
for(int i=0; i<10; 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() {
lcd.clear();
delay(1000);
lcd.home();
//run the test
runTest_5x2();
}
void runTest_5x2(){
String resultS="";
//user interface
lcd.clear();
lcd.print("Cable Tester 5x2");
lcd.setCursor(0,1);
lcd.print("Press Enc to Start");
while(digitalRead(pSwitch))
{
delay(100);
}
delay(700); //debounce
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Testing: 5x2");
lcd.setCursor(0,1);
for(int i=0; i<10; i++){
counter[i]=0;
for(int j=0; j<10; j++){
digitalWrite(endA[i], 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[i] = digitalRead(endB[i]); //read the output
if(test[i] == 1 && j!=i){ //crossed or open circuit
counter[i]++;
result[i] = 20+j;
}
else if(test[i] == 1 && j==i && result[i] <20 ){ //Good, closed circuit
result[i] = 0;
}
digitalWrite(endA[j],LOW);
//debugging
Serial.print("test1 input core ");
Serial.print(i);
Serial.print(" with output core ");
Serial.print(j);
Serial.print(" test =");
Serial.print(test[i]);
Serial.print(" counter =");
Serial.println(counter[i]);
}
Serial.print("Core ");
Serial.print(i);
Serial.print(" result = ");
if(result[i] == 0){
Serial.println(" 1");
resultS+="1";
}
else if(counter[i] == 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("FAILED");
lcd.print("FAILED");
}
else{
Serial.println("PASSED");
lcd.print("PASSED");
}
Serial.println();
lcd.setCursor(0,3);
lcd.print("Press Enc to Restart");
while(digitalRead(pSwitch))
{
delay(100);
}
delay(700); //debounce
}