Introduction

In this project, we’ll look at how to protect your home or outdoors with a presence detector. It checks that there’s nobody in the room you want to monitor, and if it detects anything it will signal it by sounding an alarm from the buzzer and writing “ALERT” on the lcd screen.

Difficulty:

Materials required

We will now list the hardware required for the project:

Schematic diagram

What's the potentiometer for?

The potentiometer adjusts the screen brightness. You can do without it by connecting 5V directly to the brown wire, and the GND that runs from the potentiometer to the screen can be connected directly to the Arduino board.

Project program

#include <LiquidCrystal.h> // librairie pour ecran
LiquidCrystal lcd(13,12,6,5,3,2); // Initialize the library
int led=7;
int PIR=4;
int buzzer=8;
int PIRstatus; // Variable to determine whether the PIR sensor detects motion or not

void setup()
{
  lcd.begin(16,2); // Initialize LCD screen
  // LED and buzzer output and PIR input
  pinMode(led, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(PIR, INPUT);
  lcd.clear();
}
void loop()
{
  PIRstatus=digitalRead(PIR); // The PIR sensor value is read
if (PIRstatus==HIGH){ // If the sensor detects movement
  lcd.clear();
  digitalWrite(led,HIGH);
  digitalWrite(buzzer,HIGH); // The buzzer sounds
  tone(buzzer, 300, 10000);       
  lcd.setCursor(0, 0);
  lcd.print("ALERT"); // The Alert message appears on the screen

  delay(7000);
  lcd.clear();
}
else
{
  lcd.setCursor(0, 0);
  lcd.print("IN SAFETY"); // If no movement is detected, we write in SAFETY
  digitalWrite(led, LOW);
  digitalWrite(buzzer, LOW);
}
delay(1000);
}

How do I upload the program onto the Arduino board?

To put the program on your Arduino board, you’ll need the Arduino Ide software. Simply open the software and load the program, then plug in the Arduino board and upload the program to it.

Project simulation

Here is the project simulation on tinkercad :