Samantha Charlotte FehlMichael Wagner
Published

LED Photon Motion Sensor

Detects when something is moving in a room and sends warnings to owner via LED lights, an alert noise, and a text message.

BeginnerWork in progress1,126
LED Photon Motion Sensor

Things used in this project

Hardware components

Photon
Particle Photon
×2
Breadboard (generic)
Breadboard (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×5
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Piezo Sensor
ControlEverything.com Piezo Sensor
×1

Software apps and online services

Maker service
IFTTT Maker service

Story

Read more

Schematics

Buzzer Circuit

Code

Motion Sensor

C/C++
This code helps the particle photon detect motion and send an alert signal.
int PIRSensor =D0;
int state = 0;
int Motion = 0;

void setup() {
  
    pinMode(D7,OUTPUT);
    pinMode(PIRSensor,INPUT);
    
}

void loop() {
  
    Motion = digitalRead(PIRSensor);
    
    if (Motion == HIGH) {
      
        digitalWrite(D7,HIGH);
        Particle.publish("motion-detected");
        
    }
    elseif (Motion == LOW) {
        digitalWrite(D7,LOW);
    }
}

Buzzer

C/C++
When a signal is received, this triggers the buzzer to alert a noise when motion was detected from the other particle.
int buzz = D0;
int state = 0;
int led = D7;

void setup ()
{
    pinMode(buzz,OUTPUT);
    pinMode(led,OUTPUT);
    
    digitalWrite(led,LOW);
    
    Particle.subscribe("motion-detected", myAlert, "2e0027000b51353432383931");
}

void myAlert(const char *event, const char *data)
{
      digitalWrite(led,HIGH);
      delay(500);
      digitalWrite(led,LOW);
      
      digitalWrite(buzz,HIGH);
      delay(200);
      digitalWrite(buzz,LOW);
      
}

Credits

Samantha Charlotte Fehl

Samantha Charlotte Fehl

2 projects • 1 follower
Michael Wagner

Michael Wagner

2 projects • 1 follower

Comments

Add projectSign up / Login