// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h> //LCD library
int val = 0; //creating an integer
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //LCD setup
void setup() {
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
lcd.print("Hello World!"); //first LCD message
pinMode(4,INPUT); //setting pin 4 (PIR sensor) as input
pinMode(6,OUTPUT); //setting pin 6 (Buzzer) as output
pinMode(13,OUTPUT); //setting pin 13 (LED) as output
}
void loop() {
// ...
val = digitalRead(4); //measuring the input of pin 4
if (val==HIGH) { //if the PIR detects motion
digitalWrite(13,HIGH); //light the LED
tone(6,100); //activates the buzzer
lcd.home(); //prevents repetition
lcd.print("HEART ATTACK "); //prints on the LCD
delay(100); //waits for a millesecond
}
else { //if the PIR doesn't detect motion
digitalWrite(13,LOW); //turns off the LED
noTone(6); //turns off the buzzer
lcd.home();
lcd.print("heart is safe");
delay(200);
}
}