Movement Sensor

hey guys!!!

Today I will show you how to make a movement sensor with all the steps to conclude the project.

I did this work for my maker space and it work, I hope that it work for you too!!!!

Step 1: Materials

first of all we need to get the materials , we will need:

- One Arduino

- One PIR Motion Sensor

- 3 Jumper Cables

- One Led Light

Step 2: Schematics

The led will go on the "gnd" and on the "13"

The red jumper cable will go on the "5V" hole on the Arduino and on the left corner on the PIR sensor

The black jumper cable will be connected on the "GND" of the power section and on the other corner of the sensor

The yellow jumper cable will go on the hole "2" and in the middle of the PIR sensor

You will connect the USB cable on the computer and and then connect with the code

Step 3: Code

int led = 13; // the pin that the LED is attached to

int sensor = 2; // the pin that the sensor is attached to int

state = LOW; // by default, no motion detected int

val = 0; // variable to store the sensor status (value)

void setup() {

pinMode(led, OUTPUT); // initalize LED as an output

pinMode(sensor, INPUT); // initialize sensor as an input

Serial.begin(9600); // initialize serial

}

void loop(){

val = digitalRead(sensor); // read sensor value

if (val == HIGH) { // check if the sensor is HIGH

digitalWrite(led, HIGH); // turn LED ON

delay(100); // delay 100 milliseconds

if (state == LOW) {

Serial.println("Motion detected!");

state = HIGH; // update variable state to HIGH

}

}

else {

digitalWrite(led, LOW); // turn LED OFF

delay(200); // delay 200 milliseconds

if (state == HIGH){

Serial.println("Motion stopped!");

state = LOW; // update variable state to LOW

}

}

}

Share

    Recommendations

    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Toys Contest

      Toys Contest
    • Big and Small Contest

      Big and Small Contest

    Discussions