/*
* This ESP8266 NodeMCU code was developed by newbiely.com
*
* This ESP8266 NodeMCU code is made available for public use without any restriction
*
* For comprehensive instructions and wiring diagrams, please visit:
* https://newbiely.com/tutorials/esp8266/esp8266-motion-sensor-piezo-buzzer
*/
#define MOTION_SENSOR_PIN D7 // The ESP8266 pin connected to the OUTPUT pin of motion sensor
#define BUZZER_PIN D1 // The ESP8266 pin connected to Buzzer's pin
int motion_state = LOW; // current state of motion sensor's pin
int prev_motion_state = LOW; // previous state of motion sensor's pin
void setup() {
Serial.begin(9600); // Initialize the Serial to communicate with the Serial Monitor.
pinMode(MOTION_SENSOR_PIN, INPUT); // Configure the ESP8266 pin to the input mode
pinMode(BUZZER_PIN, OUTPUT); // Configure the ESP8266 pin to the output mode
}
void loop() {