#include LiquidCrystal lcd( 4, 5, 6, 7, 8, 9); int latchPin = 12; int clockPin = 11; int dataPin = 13; byte pinOut = 0 int uscita = 0; int Lo1 = 0; int Lo2 = 0; int Lo3 = 0; int Lo4 = 0; int Lo5 = 0; int Lo6 = 0; int Lo7 = 0; int Lo8 = 0; int cavo = 0; int eth1 = 0; int eth2 = 0; int eth3 = 0; int eth4 = 0; int eth5 = 0; int eth6 = 0; int eth7 = 0; int eth8 = 0; int testeth1 = 0; int verifi1 = 0; int ethIn1 = 14; int ethIn2 = 15; int ethIn3 = 16; int ethIn4 = 17; int ethIn5 = 18; int ethIn6 = 19; int ethIn7 = 2; int ethIn8 = 3; void setup() { lcd.begin(16,2); lcd.setCursor(0,0); lcd.print("Cable Tester"); lcd.setCursor(4,1); lcd.print("Ethernet"); delay(3000); lcd.clear(); Serial.begin(9600); pinMode(latchPin, OUTPUT); pinMode(dataPin, OUTPUT); pinMode(clockPin, OUTPUT); pinOut = 0; pinMode(ethIn1, INPUT); pinMode(ethIn2, INPUT); pinMode(ethIn3, INPUT); pinMode(ethIn4, INPUT); pinMode(ethIn5, INPUT); pinMode(ethIn6, INPUT); pinMode(ethIn7, INPUT); pinMode(ethIn8, INPUT); } void loop() { Serial.print("----------Initialization-------------"); cavo = 0; Lo1 = 0; Lo2 = 0; Lo3 = 0; Lo4 = 0; Lo5 = 0; Lo6 = 0; Lo7 = 0; Lo8 = 0; lcd.clear(); lcd.print("Process: "); lcd.setCursor(0,1); for (int uscita=0; uscita<= 7; uscita++){ Serial.println(); Serial.print("Pin: "); Serial.print(uscita); //lcd.begin(16, 2); lcd.print(uscita + 1); pinOut = 0; bitSet(pinOut, uscita); digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, LSBFIRST, pinOut); digitalWrite(latchPin, HIGH); int eth1 = digitalRead(ethIn1); int eth2 = digitalRead(ethIn2); int eth3 = digitalRead(ethIn3); int eth4 = digitalRead(ethIn4); int eth5 = digitalRead(ethIn5); int eth6 = digitalRead(ethIn6); int eth7 = digitalRead(ethIn7); int eth8 = digitalRead(ethIn8); int testeth1 = analogRead(ethIn1); if (uscita == 0 && eth1 == 1) { Lo1 = 1; } else { if (uscita == 0 && eth3 == 1) {Lo1 = 256 ; } } if (uscita == 1 && eth2 == 1) { Lo2 = 2 ; } else { if (uscita == 1 && eth6 == 1) {Lo2 = 512 ; } } if (uscita == 2 && eth3 == 1) { Lo3 = 4 ; } else { if (uscita == 2 && eth1 == 1) {Lo4 = 1024 ; } } if (uscita == 3 && eth4 == 1) { Lo4 = 8 ; } else { } if (uscita == 4 && eth5 == 1) { Lo5 = 16; } else { } if (uscita == 5 && eth6 == 1) { Lo6 = 32; } else { if (uscita == 5 && eth2 == 1) {Lo6 = 2024 ; } } if (uscita == 6 && eth7 == 1) { Lo7 = 64; } else { } if (uscita == 7 && eth8 == 1) { Lo8 = 128; } else { } Serial.println(); Serial.print("Status of ports: "); Serial.print(eth1); Serial.print(eth2); Serial.print(eth3); Serial.print(eth4); Serial.print(eth5); Serial.print(eth6); Serial.print(eth7); Serial.print(eth8); cavo = Lo1 + Lo2 + Lo3 + Lo4 + Lo5 + Lo6 + Lo7 + Lo8 ; Serial.println(); Serial.print("Founded value of sum: "); Serial.print(cavo); } if ( cavo == 255 ) { lcd.clear(); lcd.print("Quality of cable is ok"); delay(2000); } else { if (cavo == 3008 ) { lcd.clear(); lcd.print("cable is ok"); delay(2000); } else { lcd.clear(); lcd.print("cable is not ok"); lcd.setCursor(0,1); lcd.print("there is defect"); delay(1000); lcd.clear(); if ( cavo == 2496 ) { lcd.print("Pin 2 / 6 "); delay(2000); } else { } } } lcd.print("Begin checking"); delay(1000); lcd.clear(); lcd.print("out: "); lcd.setCursor(0,1); lcd.print("in : "); uscita = 0; for (int uscita=0; uscita<= 7; uscita++){ delay(250); pinOut = 0; bitSet(pinOut, uscita); digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, LSBFIRST, pinOut); digitalWrite(latchPin, HIGH); int eth1 = digitalRead(ethIn1); int eth2 = digitalRead(ethIn2); int eth3 = digitalRead(ethIn3); int eth4 = digitalRead(ethIn4); int eth5 = digitalRead(ethIn5); int eth6 = digitalRead(ethIn6); int eth7 = digitalRead(ethIn7); int eth8 = digitalRead(ethIn8); Serial.println(); Serial.print("Resulting status of ports: "); Serial.print(eth1); Serial.print(eth2); Serial.print(eth3); Serial.print(eth4); Serial.print(eth5); Serial.print(eth6); Serial.print(eth7); Serial.print(eth8); if (eth1 == 1) { verifi1 = 1; } else { if (eth2 == 1) {verifi1 = 2; } else { if (eth3 == 1) {verifi1 = 3; } else { if (eth4 == 1) {verifi1 = 4; } else { if (eth5 == 1) {verifi1 = 5; } else { if (eth6 == 1) {verifi1 = 6; } else { if (eth7 == 1) {verifi1 = 7; } else { if (eth8 == 1) {verifi1 = 8; } else { } } } } } } } } lcd.setCursor(uscita+5,0); lcd.print(uscita+1); lcd.setCursor(uscita+5,1); lcd.print(verifi1); //delay(250); verifi1 = 0; } delay(2000); // } //} //} }