Things used in this project

Hardware components:
Photon new
Particle Photon
×2
13285 01
PIR Motion Sensor (generic)
×1
12002 04
Breadboard (generic)
×2
09590 01
LED (generic)
×1
Omron b3f 1000 image 75px
SparkFun Pushbutton switch 12mm
×1
Adafruit industries ada1536 image
Buzzer
×1
11026 02
Jumper wires (generic)
×1
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service
Google sheets
Google Sheets

Schematics

PIR Motion Sensor Schematic
Senses motion
Anqcifduupiz1zhelgqz s1oqlsurtz
BUZZER Schematic
Buzzer sounds until button is pushed
Screen shot 2017 04 12 at 10 49 32 am ornef1wgdl

Code

PIR Motion Sensor CodeC/C++
int inputPin = D0;              // choose the input pin (for PIR sensor)
int ledPin = D1;                // LED Pin
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status

int calibrateTime = 10000;      // wait for the calibration

void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode(inputPin, INPUT);     // declare sensor as input
}

void loop()
{

  // if the sensor is calibrated
  if ( calibrated() )
  {
  // get the data from the sensor
    readTheSensor();

    // report it out, if the state has changed
    reportTheData();
  }
}

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

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

void reportTheData() {

  // if the sensor reads high
  // or there is now motion
  if (val == HIGH) {

    // the current state is no motion
    // i.e. it's just changed
    // announce this change by publishing an event
    if (pirState == LOW) {
      // we have just turned on
      Particle.publish("designingiot/s17/jadam125");
      // Update the current state
      pirState = HIGH;
      setLED( pirState );
    }
  } else {
    if (pirState == HIGH) {
      // we have just turned of
      // Update the current state
      pirState = LOW;
      setLED( pirState );
    }
  }
}

void setLED( int state )
{
  digitalWrite( ledPin, state );
}
Buzzer CodeC/C++
int refill = 0;
int buzz = D0;  //pin call out for the buzzer
int buzzer = D3; //pin call out for the pushbutton

 int  x, minX;
void setup() {
    pinMode(D7, OUTPUT);
    pinMode(buzzer, INPUT_PULLDOWN);
    pinMode(buzz, OUTPUT);
    digitalWrite(buzz, LOW);
    Particle.subscribe("designingiot/s17/jadam125", myHandler, "36003a000347353138383138" );  //id for the particle


}
void myHandler(const char *event, const char *data)
{
    
}


void loop() {

 digitalWrite(D7, HIGH);
    
    if (data)
         digitalWrite(buzz, HIGH);
        refill = refill+1;
        Particle.publish("refill",String(refill)); //publishes to IFTTT to send text message and graph data
   delay(2000); //2 second delay
   digitalWrite(D7, LOW);
   
 if(digitalRead(buzzer) == HIGH)
        digitalWrite(buzz, LOW);  
        
     delay(1000);   
 
}

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Arduino Amiga Floppy Disk Reader
Easy
  • 4,637
  • 8

Work in progress

An Arduino powered floppy disk controller and reader for making disk images from old AmigaDOS floppy disks.

Micro:bit Moisture sensor
Easy
  • 180
  • 4

Protip

In this quick and easy project, you build a micro:bit moisture sensor

Quadrature Encoder Demo
Easy
  • 250
  • 4

Full instructions

Use a 3D printed encoder wheel, LED, and 2 photocells to demonstrate how a quadrature encoder works.

3D-Printed, Internet-Controlled, Self-Balancing FPV Robot
Easy
  • 1,659
  • 22

Full instructions

Open source telepresence robot that keeps its balance on two wheels. Controlled from UI in the web browser.

Piano Hero Game Using Android Things
Easy
  • 299
  • 5

Learn to play the piano with a MIDI keyboard and Android Things that includes your favourite nursery rhymes and Disney songs.

Connect Your ESP8266 to Any Available Wi-Fi Network
Easy
  • 1,872
  • 18

Full instructions

Establish an Access Point that connects your ESP8266 module to any network making a universal firmware that can be used anywhere.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login