0% found this document useful (0 votes)
29 views

Include The Library Code

Arduino code

Uploaded by

Mohammad Irfan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Include The Library Code

Arduino code

Uploaded by

Mohammad Irfan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

// include the library code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// define phase control pins


int phase[3] = {7, 8, 9};

//*********************************************************
int distance(int inputVoltage) {
if (inputVoltage >= 890 && inputVoltage < 920) {
return 8;
}
else if (inputVoltage >= 850 && inputVoltage < 890) {
return 6;
}
else if (inputVoltage >= 750 && inputVoltage < 850) {
return 4;
}
else if (inputVoltage >= 600 && inputVoltage < 750) {
return 2;
}

else return 0 ;

}
//*********************************************************

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);

// set pin mode for phase relays


for (int j = 0; j < 3; j++) {
pinMode(phase[j], OUTPUT);
}

void loop() {
digitalWrite(phase[0], HIGH);
delay(500);
int dist1 = distance(analogRead(A0));
if (dist1 == 0) {
lcd.setCursor(0, 0);
lcd.write("R: ");
lcd.setCursor(3, 0);
lcd.write("NF ");
}
else {
lcd.setCursor(0, 0);
lcd.write("R: ");
lcd.setCursor(3, 0);
lcd.print(dist1);
lcd.setCursor(4, 0);
lcd.write(" KM");
}
digitalWrite(phase[0], LOW);
//================================================
digitalWrite(phase[1], HIGH);
delay(500);
int dist2 = distance(analogRead(A0));
if (dist2 == 0) {
lcd.setCursor(8, 0);
lcd.write("Y: ");
lcd.setCursor(11, 0);
lcd.write("NF ");
}
else {
lcd.setCursor(8, 0);
lcd.write("Y: ");
lcd.setCursor(11, 0);
lcd.print(dist2);
lcd.setCursor(12, 0);
lcd.write(" KM");
}
digitalWrite(phase[1], LOW);
//=================================================
digitalWrite(phase[2], HIGH);
delay(500);
int dist3 = distance(analogRead(A0));
if (dist3 == 0) {
lcd.setCursor(0, 1);
lcd.write("G: ");
lcd.setCursor(3, 1);
lcd.write("NF ");
}
else {
lcd.setCursor(0, 1);
lcd.write("G: ");
lcd.setCursor(3, 1);
lcd.print(dist3);
lcd.setCursor(4, 1);
lcd.write(" KM");
}
digitalWrite(phase[2], LOW);
}

https://www.hackster.io/Jaymish1011/wire-fault-detector-a2a0ef

https://github.com/embeddedlab786/Underground_Cable_Fault_Detection/blob/main/
Underground_Cable_Fault_Detection.ino

You might also like