Difference between revisions of "WeMOS: D1 R1 mini PIR Sensor"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (Created page with "Sumber: http://www.esp8266learning.com/wemos-mini-pir-sensor-example.php center|300px|thumb ==Source== int pirPin = D7; int val; vo...") |
Onnowpurbo (talk | contribs) |
||
| Line 6: | Line 6: | ||
==Source== | ==Source== | ||
| − | int pirPin = D7; | + | int pirPin = D7; |
| − | int val; | + | int val; |
| + | |||
| + | void setup() | ||
| + | { | ||
| + | Serial.begin(9600); | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | val = digitalRead(pirPin); | ||
| + | //low = no motion, high = motion | ||
| − | + | if (val == LOW) | |
| − | + | Serial.println("No motion"); | |
| − | + | else | |
| − | + | Serial.println("Motion detected ALARM"); | |
| − | + | delay(1000); | |
| − | + | } | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | } | ||
Revision as of 10:18, 22 June 2023
Sumber: http://www.esp8266learning.com/wemos-mini-pir-sensor-example.php
Source
int pirPin = D7;
int val;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = digitalRead(pirPin);
//low = no motion, high = motion
if (val == LOW)
Serial.println("No motion");
else
Serial.println("Motion detected ALARM");
delay(1000); }