Surilli
Published © LGPL

Detect Motion using PIR Motion Sensor and Surilli Basic M0

PIR-based motion detector used to sense movement. They are commonly used in burglar alarms and automatically-activated lightning systems.

BeginnerFull instructions provided15 minutes550
Detect Motion using PIR Motion Sensor and Surilli Basic M0

Things used in this project

Hardware components

Surilli Basic
Surilli Basic
×1
Jumper wires (generic)
Jumper wires (generic)
×3
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Detect Motion in Your Surrounding Using PIR Motion Sensor

Code

MotionSensor

C/C++
int motion_Sensor_Pin = 10;//Motion sensor output pin is connected to pin 10 of surilli.
int Led_Pin = 13;//built-in LED pin is on pin number 13.
void setup()
{
    pinMode (motion_Sensor_Pin,INPUT);//output from motion sensor is declared as input for surilli.
    pinMode (Led_Pin, OUTPUT);//built-in LED is declared as output
    SerialUSB.begin(9600);
    digitalWrite (Led_Pin,LOW);//initially built-in LED is set LOW.
}

void loop ()
{
      delay(1000); //this delay is to let the sensor settle down before taking a reading
      int sensor_value = digitalRead(motion_Sensor_Pin);//read the value from motion sensor and stores in variable "sensor-Value"
  if(sensor_value == 1)
    {
      digitalWrite(Led_Pin,HIGH);//if sensor value is 1 then built-in LED will turn OFF.(LED inverted)
      SerialUSB.println("Motion Detected");
      SerialUSB.println(sensor_value);//prints digital value from sensor.
     // delay(100);
    }
else if (sensor_value == 0)
    {
      digitalWrite(Led_Pin,LOW);//if sensor value is 0 then built-in LED will turn ON.
      SerialUSB.println("Searching For Motion");
      SerialUSB.println(sensor_value);//prints digital value from sensor.
      //delay(100);
    }
}

Credits

Surilli

Surilli

196 projects • 47 followers
Surilli is a premiere Internet of Things centric Technology Company aimed at providing cutting edge innovative solutions.

Comments