#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h> // Library for LCD
//int
int seconds = 0;
const int pull= 6;
const int buzzer = 7;
const int silence = 5
//LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
//define list
#define relay1 8
void setup(){
Serial.begin(9600);
lcd.init(); //initialize the lcd
lcd.backlight(); //open the backlight
pinMode(pull, INPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(5, INPUT);
tone(buzzer, 800);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("CX100 Pannel");
Serial.println("CVALENX100 PANNEL NO TAMPERING!");
lcd.setCursor(0, 1);
lcd.print("V2.0");
delay(5000);
lcd.clear();
noTone(buzzer);
lcd.setCursor(0, 0);
lcd.print("System Start");
delay(5000);
}
void loop(){
nml();
delay(100);
}
//nml = Normal
//sys = System
void nml(){
if (digitalRead(6) == LOW) nmlsys();
else if (digitalRead(6) == HIGH) alarm();
}
void nmlsys(){
nmlled();
noTone(buzzer);
}
void nmlled(){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("System Normal");
Serial.println("System Normal");
lcd.setCursor(0,1);
lcd.print(" ");
delay(1000);
}
void alarm(){
int hbt= 31;
lcd.clear();
lcd.print("ALARM ");
tone(buzzer, 800);
delay(1000);
digitalWrite(relay1,HIGH);
if (digitalRead(5) == HIGH) silence1();
else;
}
void silence1(){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("System Trobble");
}