Motion detection and SMS Arduino Uno

Hello my name is Jack and i’m quit new with Arduino.

I’m trying to make a motion alarm that will send an SMS when it detects movement.

If found a few sketches on YouTube but not the one i’m looking for.
Only alarm or only SMS or to complicated.
Maybe it’s already on the forum but i couldn’t find it…

Im using the following parts:

  • Arduino Uno
  • SIM800L
  • PIR sensor

My pins are:

PIR = pin 4
Testled = pin 6
Testswitch = pin 5
TX = pin 2
RX = pin 3

This is the code i’m building:

#include <SoftwareSerial.h>
#include "Timer.h"
const int testswitch = 5;
const int testled = 6;
const int PIR = 4;

SoftwareSerial GPRS(2, 3);
boolean state, lastState;
int count;
Timer t;

void setup(){
 int checkEvent = t.every(6000,checkPIR);
 int clearEvent = t.every(18000,clearPIR);
 pinMode(testswitch, INPUT);
 pinMode(testled, OUTPUT);
 pinMode(PIR, INPUT);
 digitalWrite(testled, LOW);
 pinMode(2, OUTPUT);


void loop()
 if (digitalRead(testswitch) == HIGH){
   if (digitalRead(PIR) == HIGH){
 if (digitalRead(testswitch) == LOW){
   digitalWrite(testled, LOW);
   digitalWrite(testled, HIGH);
   digitalWrite(testled, LOW);
   digitalWrite(testled, HIGH);
   digitalWrite(testled, HIGH);
   digitalWrite(testled, LOW);
   while (count < 2){
digitalWrite(2, LOW);
   digitalWrite(2, HIGH);

void sendSMS() {
 Serial.print("Switch was turned ");
 Serial.println(state ? "on" : "off");
 GPRS.print("Switch was turned ");
 GPRS.println(state ? "on" : "off");
 GPRS.write( 0x1a ); // ctrl+Z character

void checkPIR(){
 if (digitalRead(PIR) == HIGH){
void clearPIR(){
 if (count >=2){}
 else{ count=0;}}[/i]

I’m getting this error:

exit status 1
‘checkPIR’ was not declared in this scope

Can someone help me with fixing this code?

Thank for the effort

Have you made each part work on its own?


The sms module was working and the PIR also but putting them together is a disaster for me.

How do I need to post it??

I'm new to this forum



How do I need to post it??

Instructions in this thread at the top of every forum.
How to use this forum - please read.

I used the code tag now.

The's an } before void sendSMS()

Can someone fil in the gaps of the code?


Thanks for helping me.