We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b544121 commit c309e35Copy full SHA for c309e35
motion.ino
@@ -0,0 +1,32 @@
1
+int led = 12;
2
+int pin = 2;
3
+
4
+int value = 0;
5
+int pirState = LOW;
6
7
+void setup() {
8
+ pinMode(led, OUTPUT);
9
+ pinMode(pin, INPUT);
10
+ Serial.begin(9600);
11
+}
12
13
+void loop() {
14
15
+ value = digitalRead(pin);
16
17
+ if (value == HIGH) {
18
+ digitalWrite(led, HIGH);
19
20
+ if (pirState == LOW) {
21
+ Serial.println("Motion Detected!");
22
+ pirState = HIGH;
23
+ }
24
+ }else{
25
+ digitalWrite(led, LOW);
26
27
+ if(pirState == HIGH){
28
+ Serial.println("Motion Ended!");
29
+ pirState = LOW;
30
31
32
0 commit comments