The motion sensor detects the presence of a visitor on a day that I am not in the office. This will trigger a welcome message and appropriate informational feeds to the display throughout the day with a reminder to clean up the desk at the end of the day.
The HCSR501 PIR Passive Infra Red Motion Sensor is powered by 5V but includes a 3.3V output level.
The motion sensor output is connected to the NodeMCU D7 pin. The pin is set as an input and attached to an interrupt that detects a rising edge.
#define MOTIONSENSORPIN D7 // D7 = GPIO13
void setup() {
pinMode(MOTIONSENSORPIN, INPUT);
attachInterrupt(MOTIONSENSORPIN, motionSensorActivated, RISING);
}
void motionSensorActivated() {
motionSensorDetected = true;
motionSensorDetectedCount += 1;
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.