ARDUINO UNO MOTION SENSOR!

This is a classic burglar alarm project. You can make the prototype on a breadboard for the learning purpose then solder it onto a PCB later and make it a permanent model and install in your home or college as a burglar alarm or motion detector system.

Today we will detect motion using a PIR sensor and a piezo buzzer. We will then activate loights on the alarm ringing. All this by using an arduino and some essential components for the project.

HARDWARE REQUIRED :-

  1. Arduino Uno
  2. 1x LED
  3. 2x 120 ohm resistors (Brown Black Brown)
  4. 1 x Piezo buzzer
  5. 1 x  PIR sensor
  6. Breadboard
  7. Jumper wires

HOW TO SET UP THE CIRCUIT :-

motion

The connections are pretty basic and need no formal explanation to a beginner who has done some projects on arduino or any other microcontroller. Anyway I’ll provide you an overview. :-

  • Protect the LED with a resistor(you know what I mean).
  • Protect the PIR sensor with a resistor.
  • As we donot require any readings we have not used the Analog pins and have only mae use of the digital I/O pins on the arduino uno.
  • Do not forget to ground the circuit.

CODE AND EXPLANATION :-

int LEDPin = 2; // Pin LED is connected to
int PINpiezoBuzzer = 3; // Pin Piezo Buzzer is connected to
int pirSensorPin = 4; // PIN PIR Sensor is connected to

int motionDetected = LOW; // No motion detected (initializing the motion detector’s state as LOW) i.e 0
void setup() {
pinMode(LEDPin, OUTPUT); // LED as output
pinMode(pirSensorPin, INPUT); // PIR sensor as input
pinMode(PINpiezoBuzzer, OUTPUT); // buzzer as output
Serial.begin(9600); // we can montor the motion sensing in the seriaal monitor if we want digital results alongside physical results.
delay(5000); //Time given to the PIR sensor to calibrate.
}
void loop(){
motionDetected = digitalRead(pirSensorPin); // Read the PIR sensor
if(motionDetected == HIGH) //If motion detected
{
digitalWrite(LEDPin, HIGH);
analogWrite(PINpiezoBuzzer, 200);
delay(100);
analogWrite(LEDPin, LOW);
analogWrite(PINpiezoBuzzer, 25);
delay(100);
}
else
{
digitalWrite(LEDPin, LOW);
digitalWrite(PINpiezoBuzzer,LOW);
}
}

The explanation to every line of code is mentioned alongside with it in the comment form.

 

 

 

 

COLLABORATE OTHER PROJECTS WITH THIS ONE!

  • This project once made permanently soldered on a PCB can be installed in your home or office.
  • It can be installed at such a place where you do not wish anyone to enter in your house without your prior permission. So whenever someone gets in a range of proximity with that place the buzzer goes off and you know someone is coming!. Cool isn’t it?
  • In my future projects I will be making use of the Arduino WiFi shield and we can control the range of proximity of the sensor and install it with the lock of your house and connect it with your mobile phone so whenever gets too close or touches the lock of your home when you are away you will be notified in your cell pone via Arduino web server. Another cool idea!
  • If you wish to learn about the working of PIR sensors do visit this site:-
    https://learn.adafruit.com/pir-passive-infrared-proximity-motion-sensor/how-pirs-work

 

Thank You!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s