Sie sind auf Seite 1von 3

#include <SoftwareSerial.

h>

int ledPin = 13;

int inputPin = 8; //PIR SENSOR

int pirState = LOW; //SENSOR SET TO LOW

int val = 0;

SoftwareSerial mySerial(3,2);

void setup()

pinMode(inputPin, INPUT); // PIR AS INPUT

Serial.begin(9600);

mySerial.begin(9600);

void loop()

val = digitalRead(inputPin);

if (val == HIGH) // check if the input is HIGH

if (pirState == LOW)

Serial.println("Initializing...");

delay(1000);

mySerial.println("AT"); //Once the handshake test is successful, it will back to OK

updateSerial();
mySerial.println("AT+CMGF=1"); // Configuring TEXT mode

updateSerial();

mySerial.println("AT+CMGS=\"+639368010092\"");//change ZZ with country code and xxxxxxxxxxx with


phone number to sms

updateSerial();

mySerial.print("Motion Detected. Check the Video Server."); //text content

updateSerial();

mySerial.write(26);

pirState = HIGH;

delay(5000);

else

if (pirState == HIGH)

Serial.println("Motion ended!"); // print on output change

pirState = LOW;

void updateSerial()

{
delay(500);

while (Serial.available())

mySerial.write(Serial.read());

while(mySerial.available())

Serial.write(mySerial.read());

Das könnte Ihnen auch gefallen