Motion Detector With Alarm & Message Using Arduino Microcontroller

This hands on Instructable steps you through building and programming a person detector alarm with lcd message using:

- An arduino microcontroller

- A simple breadboard with black and red wires

- A speaker or 5v buzzer

- A PIR (infra red) motion sensor

- A 1602 LCD shield w/button input

Step 1: Test for LED Light Blink

What:

Before you build anything or do any real programming, you need to first verify that your computer and the installed arduino software is properly configured to talk to your microcontroller. This process simply compiles and uploads code to the Arduino microcontroller for execution and blinks a light when it succeeds. It's the easiest and fastest test method to verify you can talk to your arduino. There is a small LED (the light) connected to pin 13 of the Arduino. When that pin is 'high' (meaning +5 volts for this Arduino clone), the LED lights.

Step 3: Motion Sensor to Detect People

What:

The motion sensor passively detects body heat (or change in the temperature profile) in a visible space for up to 20ft away. Its operation is very simple and cheap to employ, and is commonly used in burglar alarms and outdoor motion activated lights.

How:

The sensor is very simple to operate. It has only three pins. One power (+5V) pin, one ground (GND) pin and one active high OUT signal pin. Once the module powers up and averages out its field of view (this takes between 15-30 seconds), then the OUT pin will go HIGH when there is motion and low a short time after the motion subsides.

Motion Sensor Program:

Here's the code for simply turning on and off a light with your motion sensor

/////////////////////////////

//VARIABLES

int calibrationTime = 20; //the time we give the sensor to calibrate (20-30sec)

int pirPin = 2; //the digital pin connected to the sensor's output

int ledPin = 13; // the built in LED pin/////////////////////////////

void setup(){

Serial.begin(9600);

pinMode(pirPin, INPUT); // Set up the various I/O pins

pinMode(ledPin, OUTPUT);

digitalWrite(pirPin, LOW);

//give the sensor some time to calibrate (monitor state on the serial port)

Step 4: Basic Alarm by Combining Your Alarm & PIR Sensor Code

What:

You now have everything you need to make a basic alarm.

How:

You need to now load up both your alarm code as well as your PIR motion code in separate windows, along withe a new program and copy/paste content from each of the variable, setup and loop sections into one new program you should call “Simple_Person_Alarm”.

Tips: The motion sensor calibration time gives you enough time to exit the room before the alarm arms itself and tiggers on you. Once uploaded and running, you can hit the small “reset” switch on the arduino board to start the program over, giving you that calibration time delay to get out of the room without setting off the alarm yourself!

NOTE: If you have at least an hour remaining, try the more complicated LCD display with keypad buttons! It can really make your sibling detector something to be proud of!

Step 5: The LCD Keypad

What:

By itself the Arduino has limited capability for interacting with humans but with the help from the LCD it provides a simple way to display information.

How:

Hardware setup for shields is extremely easy – just power off/unplug the arduino, then carefully line up the shield pins and plug in the shield!

Lining up and Connecting/Disconnecting a Shield: There are fewer pins on the shield than there are holes in some Arduinos. To line up the pins correctly, hold the Arduino with the USB connection to your left and the shield with the buttons below the display in your right hand. Line up the farthest right shield pins with the farthest right Arduino holes. Carefully make sure all the remaining pins are aligned with the corresponding holes.

Whenever you use any shield, it's important to understand what pins the shield actually use, both for being able to communicate with it and for knowing any conflicts which could occur if you want to stack shields. Above is a table of the pins used by the LCD shield.

Program to Display LCD:

Here's a simple program setting up and displaying a custom message.

#include<LiquidCrystal.h>

// Create the LiquidCrystal object and define the pins used on the LCD shield

lcd.begin(16, 2); // Put the cursor on the first column of the first row

lcd.setCursor(0, 0); lcd.print("Custom Message");

void loop()

{

lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over

lcd.print(millis()/1000); // display seconds elapsed since powerup

}

Step 6: Conclusion

Combine the alarm, motion sensor, and LCD code into one file and upload to arduino. The final product will have a motion sensor that when triggered create a buzz noise and display a message on the LCD screen.