Jackson Hardy
Published

Alarm Security System

A two-part system that senses and records motion at the front door, then sounds an alarm placed beside your bed, for example.

IntermediateFull instructions provided6 hours250
Alarm Security System

Things used in this project

Hardware components

Buzzer
Buzzer
×1
Photon
Particle Photon
×1
Internet Button
Particle Internet Button
This could be replaced with a photon on an additional breadboard
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2
Male/Female Jumper Wires
Male/Female Jumper Wires
×3
Male/Male Jumper Wires
×2
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Maker service
IFTTT Maker service
Google Sheets
Google Sheets
Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

PIR Motion Sensor (Publisher)

Pir k6knfygztu

PIR Motion Sensor Schematic

Buzzer Schematic

Buzzer (Subscriber)

Buzzer s7kl2p5ftd

Code

PIR Motion Sensor (Publisher)

C/C++
particlebuild.io
int PIRpin = D1;
int buzzerpin = D2;
int ledpin = D7;
int PIRstate = LOW;
int val = 0;

int calibrateTime = 10000;

void setup() {
    pinMode(PIRpin, INPUT);

    pinMode(buzzerpin, OUTPUT);

    pinMode(ledpin, OUTPUT);
}

void loop() {
    if(calibrated())
    {
        readTheSensor();
        reportTheData();
    }

}
void readTheSensor()
{ val = digitalRead(PIRpin); }

bool calibrated() {
    return millis() - calibrateTime > 0;
}

void reportTheData()
{ if(val == HIGH){
    if(PIRstate == LOW){
       Particle.publish("detected_motion", "1");
        
        PIRstate = HIGH;
        setLED(PIRstate);
    }
} else {if (PIRstate == HIGH){
    PIRstate = LOW;
    setLED(PIRstate);
}
}
}

void setLED(int state)
{
    digitalWrite(ledpin, state);
}

Buzzer (Subscriber)

C/C++
particle.io
int led = D7;
int buzzer = D2;
int state = 0;



void setup() {

pinMode(led, OUTPUT);
digitalWrite(led, LOW);

pinMode(buzzer,OUTPUT);
digitalWrite(buzzer, LOW);

Particle.subscribe("detected_motion", myHandler, "340042001447363333343437");

}




void myHandler(const char *event, const char *data)
{
  digitalWrite(led, HIGH);
  delay(250);
  digitalWrite(led, LOW);
  delay(250);
  
  digitalWrite(led, HIGH);
  delay(100);
  digitalWrite(led, LOW);
  delay(100);
  
  analogWrite(buzzer,50);
  delay(500);
  analogWrite(buzzer,0);
  
  delay(250);
  
  analogWrite(buzzer,100);
  delay(250);
  analogWrite(buzzer,0);
}

Credits

Jackson Hardy

Jackson Hardy

1 project • 0 followers
I am a Mechanical Engineering Student at UNCC

Comments

Add projectSign up / Login