Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
Tarantula3DIYables
Published

PIR Sensor Tutorial - With Or Out Arduino

Just before creating my next tutorial, which will be using a PIR sensor, I thought I might create a separate tutorial for PIR Sensor.

BeginnerProtip1 hour50,379
PIR Sensor Tutorial - With Or Out Arduino

Things used in this project

Story

Read more

Schematics

pir_schema_-_no_arduino_(00_00_28_300)_LRUakuqPMx.png

pir_schema_-_arduino_(00_00_32_500)_nwG9NMO2At.png

Code

Code.ino

Arduino
int LED = 13;             // the pin that the LED is atteched to
int PIR = 2;              // the pin that the sensor is atteched to

void setup() {
  pinMode(LED, OUTPUT);   // initalize LED as an output
  pinMode(PIR, INPUT);    // initialize sensor as an input
  Serial.begin(9600);     // initialize serial
}

void loop(){
  if (digitalRead(PIR) == HIGH) { // check if the sensor is HIGH
    digitalWrite(LED, HIGH);      // turn LED ON 
    Serial.println("Motion detected!"); 
    delay(100);                   // delay 100 milliseconds 
  } 
  else {
    digitalWrite(LED, LOW);       // turn LED OFF
    Serial.println("Motion stopped!");
    delay(100);                   // delay 100 milliseconds
  }
}

Credits

Tarantula3

Tarantula3

67 projects • 85 followers
There were 1000+ sperms but I was the fastest one..
DIYables

DIYables

0 projects • 79 followers
I would like to invite you to join and add your projects to DIYables platform https://www.hackster.io/diyables

Comments