ESP8266 Arduino HC-SR501 PIR 인체 동작 감지센서 구입하기>>

ESP8266 WeMos D1 mini(위모스 보드) and PIR Motion Detector Sensor Connection

PIR Sensor ———- ESP8266 ESP-12F Board(WeMos D1)
========= =================
VCC —————– VCC (or V5)
OUT —————– GPIO 4 (or D2)
GND —————– GND (or G)

ESP8266-WeMos-D1-mini_HC-SR501_PIR-Motion-Detector

Sketch ESP8266_PIR-Motion_Detector.ino

// HC-SR501 Motion Detector
// Sample Sketch

int ledPin = 2;  // LED On: Pin GPIO 2 of ESP-12F
int pirPin = 4; // Input for HC-SR501: Pin GPIO 4

int pirValue; // Place to store read PIR Value


void setup() {
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);

  digitalWrite(ledPin, LOW);

}

void loop() {
  pirValue = digitalRead(pirPin);
  digitalWrite(ledPin, !pirValue); //LED ON when value is LOW
  Serial.println(pirValue);

}

Leave a Reply