The circuit in question appears to be a fault detection system that utilizes an Arduino UNO microcontroller to control a series of relays and gather sensor data. The system also includes visual indicators (LEDs) and an audible alert (buzzer). The Arduino UNO drives a 16x2 LCD display for user interface, indicating the status of three channels (presumably Red, Yellow, and Blue) and the distance to a fault if detected. The circuit includes multiple toggle switches, resistors, diodes, and relays to manage the flow of power and to protect against voltage spikes.
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);
#define sensor A0
#define relay1 8
#define relay2 9
#define relay3 10
#define buzzer 13
int read_ADC;
int distance;
byte symbol[8] = {
B00000,
B00100,
B00100,
B00100,
B11111,
B01110,
B00100,
B00000};
void setup() {
pinMode(sensor,INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(buzzer, OUTPUT);
lcd.createChar(1, symbol);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0); // set the cursor to column 0, line 2
lcd.print("Welcome to Cable");
lcd.setCursor(0, 1); // set the cursor to column 0, line 2
lcd.print("Fault Detection");
delay(2000);
lcd.clear();
}
void loop(){
lcd.setCursor(1,0);
lcd.print("R");
lcd.write(1);
lcd.setCursor(7,0);
lcd.print("Y");
lcd.write(1);
lcd.setCursor(13,0);
lcd.print("B");
lcd.write(1);
digitalWrite(relay1,HIGH);
digitalWrite(relay2,LOW);
digitalWrite(relay3,LOW);
delay(500);
data();
lcd.setCursor(0,1);
if(distance>0){lcd.print(distance); lcd.print("KM ");}
else{lcd.print(" NF ");}
digitalWrite(relay1,LOW);
digitalWrite(relay2,HIGH);
digitalWrite(relay3,LOW);
delay(500);
data();
lcd.setCursor(6,1);
if(distance>0){lcd.print(distance); lcd.print("KM ");}
else{lcd.print(" NF ");}
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
digitalWrite(relay3,HIGH);
delay(500);
data();
lcd.setCursor(12,1);
if(distance>0){lcd.print(distance); lcd.print("KM ");}
else{lcd.print(" NF ");}
}
void data(){
read_ADC = analogRead(sensor);
distance = read_ADC/100;
if(distance>9)distance = 0;
if(distance>0){
digitalWrite(buzzer,HIGH);
delay(200);
digitalWrite(buzzer,LOW);
delay(200);
}
}
This code is designed to read sensor data and display the distance to a fault on an LCD. It controls three relays and a buzzer for alerts. The LCD displays "Welcome to Cable Fault Detection" on startup and then cycles through the relay states, displaying the distance or "NF" (no fault) accordingly.