Difference between revisions of "WeMOS: D1 R1 mini PIR Sensor"

From OnnoWiki
Jump to navigation Jump to search
(Created page with "Sumber: http://www.esp8266learning.com/wemos-mini-pir-sensor-example.php center|300px|thumb ==Source== int pirPin = D7; int val; vo...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
Sumber: http://www.esp8266learning.com/wemos-mini-pir-sensor-example.php
 
Sumber: http://www.esp8266learning.com/wemos-mini-pir-sensor-example.php
  
 +
[[File:PIR Interfacing Diagram2.png|center|300px|thumb]]
  
 
[[File:Wemos-and-PIR bb-1024x612.png|center|300px|thumb]]
 
[[File:Wemos-and-PIR bb-1024x612.png|center|300px|thumb]]
Line 6: Line 7:
 
==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
  
void setup()
+
  if (val == LOW)
{
+
    Serial.println("No motion");
  Serial.begin(9600);
+
  else
}
+
    Serial.println("Motion detected  ALARM");
  
void loop()
+
  delay(1000);
{
+
}
  val = digitalRead(pirPin);
 
  //low = no motion, high = motion
 
  if (val == LOW)
 
  {
 
    Serial.println("No motion");
 
  }
 
  else
 
  {
 
    Serial.println("Motion detected  ALARM");
 
  }
 
  delay(1000);
 
}
 
  
  

Latest revision as of 11:38, 25 April 2024

Sumber: http://www.esp8266learning.com/wemos-mini-pir-sensor-example.php

PIR Interfacing Diagram2.png
Wemos-and-PIR bb-1024x612.png

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);
}


Referensi

Pranala Menarik