Madie TankardMorgan AskewJeremy Mace
Published

MEGR3171: Spot the Sneak - Christmas Motion Detector

Use the motion detector to notify you of when your kids try to sneak-a-peek at the presents!

BeginnerFull instructions provided8 hours609
MEGR3171: Spot the Sneak - Christmas Motion Detector

Things used in this project

Hardware components

Argon
Particle Argon
×3
Breadboard (generic)
Breadboard (generic)
×3
PIR Sensor, 7 m
PIR Sensor, 7 m
×1
Buzzer
Buzzer
×1
LED (generic)
LED (generic)
×2
High Brightness LED, White
High Brightness LED, White
×1
Jumper wires (generic)
Jumper wires (generic)
×10
Art Supplies/Cardboard for Reindeer
×1

Software apps and online services

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

Story

Read more

Schematics

Argon #1 - PIR Motion Sensor

This Argon will sense motion and publish an event that will activate the other two Argons and will create a Google Sheet.
Note: The Fritzing program did not have the following components: Particle Argon, PIR Motion Sensor, and Passive Buzzer. A Particle Photon was used as a substitute for the Particle Argon. The Sensor and Buzzer were added individually using screenshots obtained from Google.

Argon #2 - Buzzer

Once the Sensor Argon has been activated, this Argon will make a buzzing sound for a certain amount of time. After a little while, the Buzzer Argon will publish an event that will reactivate the Sensor Argon.
Note: The Fritzing program did not have the following components: Particle Argon, PIR Motion Sensor, and Passive Buzzer. A Particle Photon was used as a substitute for the Particle Argon. The Sensor and Buzzer were added individually using screenshots obtained from Google.

Argon #3 - LED Light(s)

Once Argon #1 has been activated, the LED Argon will blink two red lights for a certain amount of time. After a little while, the LED Argon will publish an event to reactivate the Sensor Argon.
Note: The Fritzing program did not have the following components: Particle Argon, PIR Motion Sensor, and Passive Buzzer. A Particle Photon was used as a substitute for the Particle Argon. The Sensor and Buzzer were added individually using screenshots obtained from Google.

Code

Argon PIR Motion Sensor Code

C/C++
This is the primary Argon that will activate an output response from the Buzzer and LED Light.
//This is for the first particle argon - the motion senor - will publish event to second and third argon - by Morgan Askew
//Name of device = maskew2motionsensor , Name of event - PIRMotion_detectedmaskew2 , "Motion Detected!" = Message on Particle app once event occurs
//"e00fce6811dd0345b92fe5e9" is the ID for Morgan's Motion Sensor Argon, "messagedreceivedjmace7" is the name of Jeremy's event (how it communicates to each other)

int ledPIN = D5;
int PIRsensor = D7;
int pirState = LOW;     //Initial State = No motion

void setup() {
    //This tells the particle argon if a pin is an output or an input, and publishes/subscribes to that specific function
    Particle.subscribe("messagereceivedjmace7", confirm, "e00fce6811dd0345b92fe5e9");
    Particle.subscribe("Speaker_madie", confirm, "e00fce681ca78aed6db8e652");
    pinMode(PIRsensor, INPUT);  //This states the PIRsensor will be an input function
    pinMode(ledPIN, OUTPUT);    //This states the ledPIN will be an output function
    
}

void loop()
{
    if (digitalRead(PIRsensor) == HIGH) {
      // we have just turned on
      Particle.publish("PIRMotion_detectedmaskew2", "Motion Detected!", PUBLIC);
    }
      delay(500);     
}

void confirm(const char *event, const char *data)
{
    //this subscibes to the "confirm" event meaning the other photon has received the "Motion Dectected!" even and will flash the LED and make the buzzer sound
   digitalWrite(ledPIN, HIGH);
   delay(100);
   digitalWrite(ledPIN, LOW);
   
}

Argon LED Code

C/C++
This is used to output 2 LED lights when an event is published by the PIR Motion Sensor
// LED Light Argon Code - by Jeremy Mace
//"PIR_Motion_detectedmaskew2" is the name of the  IFTTT event, "e00fce6898a41f05540a07d4" is the name of Morgan's ID for her argon
//"messagereceivedjmace7" is the name of IFTTT event, proves 2 part communication

int led1 = D0; 

int led2 = D7; 



void setup() {


    Particle.subscribe("PIRMotion_detectedmaskew2", alarm, "e00fce6898a41f05540a07d4");


  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

}




void alarm(const char *event, const char *data) {
  // To blink the LED, first we'll turn it on...
 
    if(event)

{
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);

  // We'll leave it on for .5 second...
  delay(500);

  // Then we'll turn it off...
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);

  // Wait .25 second...
  delay(250);
  
  
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);

  // We'll leave it on for .5 second...
  delay(500);

  // Then we'll turn it off...
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);

  // Wait 1 second...
  delay(1000);
  
    Particle.publish("messagereceivedjmace7", "confirmed", PUBLIC);
    
}
delay(10000);
}
void loop()
{
}

Argon Buzzer Code

C/C++
This is used to output a chosen frequency when an event is published by the PIR Motion Sensor.
void setup()
///Buzzer by Madie
{                
    pinMode(D2, OUTPUT);  // buzzer on pin D2
    Particle.subscribe("PIRMotion_detectedmaskew2", alarm, "e00fce6898a41f05540a07d4"); //madie's argon is listening to morgan's PIR sensor
    Particle.subscribe("messagereceivedjmace7", alarm); //jeremy's argon
     tone(D2, 3500, 2000); //desired pin, frequency and time
    
}

void alarm(const char *event, const char *data) //what the buzzer argon is looking for
{
    if (event)
    {
      tone(D2, 3500, 2000); //chosen frequency and time
      Particle.publish("Speaker_madie", PUBLIC); //notifcation
      Particle.publish("PIRMotion_detectedmaskew2", "buzzbuzz", PUBLIC); //notifcation
    }
}

Credits

Madie Tankard

Madie Tankard

1 project • 0 followers
Morgan Askew

Morgan Askew

1 project • 0 followers
Jeremy Mace

Jeremy Mace

1 project • 0 followers

Comments