Harrison TharringtonAlex Cockman
Published

Snack Snatcher Stopper 3000

Imagine coming home from a long day of work. You're starving and tired. All you want is a huge bowl of Count Chocula cereal and it's GONE!

IntermediateProtip12 hours38
Snack Snatcher Stopper 3000

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×2
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
LED (generic)
LED (generic)
×1
Particle lcd 1602 Module
×1
PHPoC Bread Board
PHPoC Bread Board
×1
Argon
Particle Argon
×2

Software apps and online services

Maker service
IFTTT Maker service
Fritzing
Google Sheets
Google Sheets

Story

Read more

Schematics

LCD Display Circuit Diagram

LCD Display Download

Download Our Circuit Diagram

PIR Sensor Circuit Diagram

PIR Sensor Download

Download Our Circuit Diagram

Number of Times PIR Sensor Ran per Day

This is a google sheet that is linked with the argon so every time motion is detected, the google sheet will add one tally.
https://docs.google.com/spreadsheets/d/1mYyYRFZPR1e9trOts2_gywwagp4FPLL4pdnLPXyPI-o/edit#gid=0 . Is the link

Code

LCD Display Code

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <LiquidCrystal.h>

#define DHTPIN D5

#define DHTTYPE DHT11

LiquidCrystal lcd(D0, D1, D2, D3, D4, D5);

int inPin = D13;              
int ledPin = D7;                
int pIRstate = LOW;             
int val = 0;  

void setup() {
    lcd.begin(16,2);
    lcd.setCursor(4,0);
    lcd.print("Welcome");

Particle.subscribe("Intruder_Alert", Movement);

  pinMode( ledPin, OUTPUT );
  pinMode(inPin, INPUT); 
}

void Movement(const char *event, const char *data) {

if(data == "Movement")
    
    lcd.begin(16,1);
    lcd.setCursor(1,4);
    lcd.print("INTRUDER ALERT");
    delay(5000);
    lcd.noDisplay();
    lcd.begin(16,2);
    lcd.setCursor(4,0);
    lcd.print("Welcome");
    delay(1500);
    lcd.begin(16,1);
    lcd.setCursor(1,4);
    lcd.print("ToTheSnackShow");
    
}

PIR SensorCode

C/C++
// First photon, Motion sensor
int inputPin = D0;              
int ledPin = D7;                
int pirState = LOW;             
int val = 0;                    

int calibrateTime = 10000;      

void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode(inputPin, INPUT);     
}

void loop()
{  
  if ( calibrated() )
  {

    readTheSensor();

   
    reportTheData();
  }
}

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

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

void reportTheData() {

  
  if (val == HIGH) {

   
    if (pirState == LOW) {
     
      Particle.publish("Intruder_Alert", "Movement");
      
      pirState = HIGH;
      setLED( pirState );
    }
  } else {
    if (pirState == HIGH) {
     
      pirState = LOW;
      setLED( pirState );
    }
  }
}


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

void loop() {
  // Get some data
  String data = String(10);
  // Trigger the integration
  Particle.publish("Intruder_Alert", data, PRIVATE);
  // Wait 60 seconds
  delay(60000);
}

void setup() {
  // Subscribe to the integration response event
  Particle.subscribe("hook-response/Intruder_Alert", myHandler, MY_DEVICES);
}

void myHandler(const char *event, const char *data) {
  // Handle the integration response
}

Credits

Harrison Tharrington
1 project • 1 follower
Alex Cockman
4 projects • 5 followers
Thanks to Taylor Brady and Ezequiel Oreuz.

Comments