Created
August 27, 2018 14:10
-
-
Save e-Gizmo/aa6a8a646af07105e9809f8a04156fa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Motion Detector using PIR Human Motion sensor | |
This is an example sketch where you will determine if there's | |
a motion on your surrounding with LED indicator. Motion Detected, | |
LED is HIGH. | |
*/ | |
int LED_INDICATOR = 13; | |
int PIR_SENSOR = 2; | |
int STATS = LOW; | |
int VALUE = 0; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(LED_INDICATOR, OUTPUT); | |
pinMode(PIR_SENSOR, INPUT); | |
} | |
void loop(){ | |
VALUE = digitalRead(PIR_SENSOR); | |
if (VALUE == HIGH) { | |
digitalWrite(LED_INDICATOR, HIGH); | |
delay(100); | |
if (STATS == LOW) { | |
Serial.println("MOTION DETECTED! - HIGH"); | |
STATS = HIGH; | |
} | |
} | |
else { | |
digitalWrite(LED_INDICATOR, LOW); | |
delay(200); | |
if (STATS == HIGH){ | |
Serial.println("MOTION STOPPED!"); | |
STATS = LOW; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment