Child pages
  • Alarm Project using PIR Motion Sensor
Skip to end of metadata
Go to start of metadata

  

Introduction

This page is about using a PIR (Passive Infrared) Motion sensor to trigger an alarm using an Arduino compatible MCU board called- Gemma, created by Adafruit part no. 1528-1297-ND

PIR sensors are triggered by changes in heat radiated from our bodies or other energy source by comparing the difference between the heat source and surrounding area.  An amplifier and ASIC are used in the Panasonic brand to make detection almost like a Schmitt trigger effect and easy to interface to any microcontroller.  There is a plastic Fresnel lens on each PIR sensor to enable detection of various zoned areas.   

                            

The diagram below shows the timing of the PIR sensor from power up where there is a bit of a delay before the sensor stabilizes and is ready for detection (~15 seconds by my testing)

 

Circuit operation: When the PIR sensor detects a heat change, the signal pin, rises to a high voltage, when the MCU is polling for a high input, uses the true condition to turn on another pin (D2 below), which turns on the audio alarm (note that the alarm operates off of DC and has it's own pulsing circuit).  At almost the same time, pin D1 brings in a series of pulses (set up by the Adafruit NEOPIXEL include library) to help flash the 16 LEDs red.  This creates a loud, irritating and bright flashing red lights- perfect for scaring or alarming someone for a special purpose.  Panasonic PIR Motion Sensors Datasheet Link.

Hardware Requirements

This alarm project was created with the following part numbers from Digi-Key:

Alarm Project Application used in- "The Haunted Woods" 

Software Requirements

Hardware Design

Schematic drawn in Scheme-it

Example Application

 

#include < Adafruit_NeoPixel.h >

// Note 1 = pin one on Gemma
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, 1, NEO_GRB + NEO_KHZ800); 

int Pin2 = 2;
int Pin0 = 0;

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

  strip.setPixelColor(3, 0, 0, 127); // set color to blue
  strip.setBrightness(255); // setting brightness for Neopixel to high

  pinMode(Pin2, OUTPUT); // output for audio alarm
  pinMode(Pin0, INPUT); // for receiving the signal from the PIR sensor
}
 
void loop() {

  int z = 0;

  if (digitalRead(Pin0 == HIGH)) // if receives a logic one (high) then process next set of instructions
  {
    digitalWrite(Pin2, HIGH); // turn on alarm (...energize the MOSFET gate)

    for (int i = 0; i < 16; i++) // for turning on each Neopixel

    {
      strip.setPixelColor(i, 255, 0, 0); // set color to red
      strip.show();
      delay(100);
      z = 20000;
    }

    for (int i = 0; i < 16; i++) {
      strip.setPixelColor(i, 0, 0, 0); // turn off Neopixels
      strip.show();
    }
  }
  digitalWrite(Pin2, LOW); // turn off alarm (...turning off MOSFET)            
  delay(z); // long delay to wait for the crowd to pass
}

 Questions or comments please email me at john.leduc@digikey.com

 

  • No labels