Christiaan Neil Burger
Published © LGPL

My Motion Activated SMS sender

When motion is sensed, an SMS will be sent to say that motion was detected.

IntermediateFull instructions provided4,058
My Motion Activated SMS sender

Things used in this project

Story

Read more

Schematics

PIR Motion sensor and 1sheeld

Code

Motion Activated SMS Sender

Java
#include <OneSheeld.h> 
int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int PIR = LOW;    //Sets the Motion sensor to low        
int val = 0;                    
          

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
   OneSheeld.begin(); 

 
}

void loop(){
  //loop starts
  
    val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON   
    delay(150);//delays the wait for 1/15 of a second 

    
    if (PIR == LOW) { //if motion is detected
      
       SMS.send("0123456789","Motion DETECTED"); 
       //^^^^^^^^^replace 0123456789 with your number, add your own Message
       PIR = HIGH; //sets the value to high so that we avoid a infinite loop
    
    }
  } else {
      digitalWrite(ledPin, LOW); // turn LED OFF

        
      if (PIR== HIGH){ // if its HIGH set to low sothat it is checked again


      PIR = LOW;
    }
    //loop ends an restarts
  }
}

Credits

Christiaan Neil Burger

Christiaan Neil Burger

3 projects • 9 followers
Friendly an love to solve problems and invent.

Comments