#define led_1 4
#define pbStartPin 2
#define pbStopPin 15
#define buzzerPin 12
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 16, 2);
boolean status = false;
void setup() {
Serial.begin(9600);
Serial.println("Panic Button Simulation");
LCD.init();
LCD.backlight();
LCD.setCursor(0, 0);
LCD.print("RSAM Bukittinggi");
LCD.setCursor(0, 1);
LCD.print("By : Dendi F");
pinMode(led_1, OUTPUT);
pinMode(pbStartPin, INPUT);
pinMode(pbStopPin, INPUT);
digitalWrite(led_1, LOW);
}
void loop() {
if(digitalRead(pbStartPin) == HIGH){
status = true;
LCD.clear();
Serial.println("Button : ON");
LCD.setCursor(0, 0);
LCD.print("Button : ON");
LCD.setCursor(0, 1);
LCD.print("CODE BLUE");
delay(500);
}
if(digitalRead(pbStopPin) == HIGH){
status = false;
Serial.println("Button : Off");
LCD.clear();
LCD.setCursor(0, 0);
LCD.print("RSAM Bukittinggi");
LCD.setCursor(0, 1);
LCD.print("By : Dendi F");
delay(500);
}
if(status){
digitalWrite(led_1, HIGH);
delay(500);
digitalWrite(led_1, LOW);
delay(500);
tone(buzzerPin, 1500);
noTone(buzzerPin);
delay(1000);
tone(buzzerPin, 500, 1000);
delay(1000);
}
}