#include <LiquidCrystal.h>
LiquidCrystal lcd (9,10,11,12,13,14);
int s1 = 1;
int s2 = 2;
int s3 = 3;
int s4 = 4;
int s5 = 5;
int s6 = 6;
int s7 = 7;
int s8 = 8;
int led = 15;
int buttonstate1 = 0;
int buttonstate2 = 0;
int buttonstate3 = 0;
int buttonstate4 = 0;
int buttonstate5 = 0;
int buttonstate6 = 0;
int buttonstate7 = 0;
int buttonstate8 = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
lcd.begin(16,2);
pinMode(s1, INPUT);
pinMode(s2, INPUT);
pinMode(s3, INPUT);
pinMode(s4, INPUT);
pinMode(s5, INPUT);
pinMode(s6, INPUT);
pinMode(s7, INPUT);
pinMode(s8, INPUT);
pinMode(led, OUTPUT);
lcd.print("fault detection");
delay(500);
}
void loop() {
buttonstate1 = digitalRead(s1);
Serial.print("switch1 = ");
Serial.println(buttonstate1);
delay(500);
buttonstate2 = digitalRead(s2);
Serial.print("switch2 = ");
Serial.println(buttonstate2);
delay(500);
buttonstate3 = digitalRead(s3);
Serial.print("switch3 = ");
Serial.println(buttonstate3);
delay(500);
buttonstate4 = digitalRead(s4);
Serial.print("switch4 = ");
Serial.println(buttonstate4);
delay(500);
buttonstate5 = digitalRead(s5);
Serial.print("switch5 = ");
Serial.println(buttonstate5);
delay(500);
buttonstate6 = digitalRead(s6);
Serial.print("switch6 = ");
Serial.println(buttonstate6);
delay(500);
buttonstate7 = digitalRead(s7);
Serial.print("switch7 = ");
Serial.println(buttonstate7);
delay(500);
buttonstate8 = digitalRead(s8);
Serial.print("switch8 = ");
Serial.println(buttonstate8);
delay(500);
if(buttonstate1 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable1 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
delay(500);
}
if(buttonstate2 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable2 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
delay(500);
}
if(buttonstate3 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable3 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
delay(500);
}
if(buttonstate4 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable4 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
}
if(buttonstate5 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable5 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
delay(500);
}
if(buttonstate6 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable6 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
delay(500);
}
if(buttonstate7 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable7 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
delay(500);
}
if(buttonstate8 == HIGH)
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("cable8 fault");
digitalWrite(led, HIGH);
delay(500);
}
else
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print("all are safe");
digitalWrite(led, LOW);
delay(500);
}
}