Don't Steal My Cookies!

Made by Stamp Siripanich

A SparkCore prototype of a system that will alert when someone is trying to steal cookies from a jar without asking for permission!

Created: January 27th, 2015

0

Design Purpose

A system that will alert when someone is trying to steal cookies from a jar without asking for permission!


Design Description

The alert system is based on the use of two sensors, Photoresistor and Force Sensitive Resistor, with a red LED as the visual feedback.

The circuit includes:

● Spark Microcontroller

● Breadboard

● Jumper Wires

● A 1kΩ Resistor

● A single color LED

● Two 10kΩ Resistor

● A Photoresistor

● A Force Sensitive Resistor

0


Here is what the circuit looks like in real life!

0

Design Scenario

When the top knob of the cookies jar is touched, the Force Sensitive Resistor which is embedded in the top knob will be trigger, and as the lid is being lifted, the Photoresistor would also be activated. These two sensors combined would set off a warning to the cookies jar owner, informing the owner that the safety of the cookies has been compromised!

Meanwhile, when the owner wants to eat a cookie in the jar, the owner could avoid tipping off the alarm by not touching the top knob, but lift the lid by holding the whole top instead. Bon Appétit!

0


SparkCore Coding

The coding has been done based on the foundation of the "Using a Photoresistor" and "Using a Force Sensitive Resistor" tutorials of Carnegie Mellon University's Designing for the Internet of Things class, and "Turn on LED when it's dark - Spark Core" found on Higepon’s blog.

0
//define the warning led
int redLed = D0;
//define sensors sources
int lightPin = A0;
int lightReading = 0;
int fsrPin = A1;
int fsrReading = 0;
bool isSteal = false;


void setup()
{
  pinMode(redLed, OUTPUT);
  digitalWrite(redLed, LOW);
  //show sensors variables on sparkcloud
  Spark.variable("force", &fsrReading, INT);
  Spark.variable("light", &lightReading, INT);
}


void loop()
{
    //get fsr sensor readings
    fsrReading = analogRead(fsrPin);
    //get light sensor readings
    lightReading = analogRead(lightPin);

    bool notTouch = fsrReading <= 100;
    bool lidOpen = lightReading >= 700;

    Serial.print(lidOpen);
    //light sensor on, fsr off, redled off
    if (notTouch && lidOpen) {
    //light sensor on, fsr on, redled on
    } else if (!notTouch && lidOpen) {
        //someone is stealing, led on!
        digitalWrite(redLed, HIGH);
        isSteal = true;
        //the warning led will stay on for 10 seconds after the alert system has been activated
        delay(10000);
        //turn off the warning led after the 10 seconds is over
        digitalWrite(redLed, LOW);
    } else {
        digitalWrite(redLed, LOW);
        isSteal = false;
        //no one is opening the jar
    }
}
Click to Expand
0

Video of the Circuit in Use

0
0


SparkCloud Variable Readings

Photo 1. When the Photoresistor is sensing light in a dark scenario, and the Force Sensitive Resistor is untouched

Photo 2. When the Photoresistor is sensing light in a well lit scenario, and the Force Sensitive Resistor is untouched

Photo 3. When the Photoresistor is sensing light in a well lit scenario, and the Force Sensitive Resistor is pressed

x
Share this Project


About

A SparkCore prototype of a system that will alert when someone is trying to steal cookies from a jar without asking for permission!