A little bit of back story.
This project was actually built before my Motion Activated Door Display aka. Arduino Project #8.
Because, I was still waiting for the WS2812B boards that time and remembered and asked my self "Hey! I have a couple of PIR motion sensors in my Arduino Arsenal. Now, what can I do with it?".
So, I came up with this one.
I guess that's it.
Just watch the video if you want to know more.
Thanks!
Here are some helpful Images and links on how to connect and setup things.
PIR Motion Calibration: http://helpdesk.txplore.com/support/solutions/articles/35000024880-how-to-calibrate-your-pir-infrared-sensor-
******************************************************************************
Social Media Links To Follow (I mean, if you want to):
Facebook - https://fb.me/HeathenHacks
Twitter - https://twitter.com/HeathenHacks
Instagram - https://instagr.am/HeathenHacks
******************************************************************************


🛠️ เจาะลึกเบื้องหลังการทำงาน (Deep Dive / Technical Analysis)
Leaving a bathroom light explicitly blazing for 8 hours is fundamentally inefficient. The PIR Motion Controlled Relay system immediately terminates unnecessary AC grid consumption! By deploying a completely digital PIR (Passive InfraRed) sensor, the Arduino executes a silent, terrifyingly precise thermal surveillance operation! It detects the exact moving heat signatures generated exclusively by human biology crossing a faceted plastic optical dome. Upon confirmation, the Arduino rips a high-voltage mechanical Relay HIGH, effortlessly slamming 220 Volts straight into the incandescent room lights in absolute milliseconds!
Demystifying the PIR Biological Tracking Envelope
The HC-SR501 sensor is NOT an ultrasonic radar! It relies exclusively upon human body heat (98.6°F / 37°C) radiating invisible photons in the 9-10 micrometer wavelength!
- The white plastic dome is a highly complex Fresnel Lens that physically fractures the room into tiny microscopic optical zones natively.
- A human walking shifts their heat profile aggressively from "Zone A" to "Zone B."
- The pyroelectric semiconductor inside the PIR detects this brutal temperature delta instantaneously, forcing the module's Digital
OUTpin completely toHIGH (3.3V)!
int pirSensorPin = 2; // Receives the 3.3V logic strike from the SR501!
int relayPin = 8; // Drives the fierce 220V Opto-Relay!
unsigned long lastMotionTime = 0; // The timeout clock!
void loop() {
if (digitalRead(pirSensorPin) == HIGH) {
// Biological thermal anomaly discovered!
digitalWrite(relayPin, HIGH); // Smashes the Relay closed! Lights ON!
lastMotionTime = millis(); // Reset and lock the timeout clock!
}
// The brutal 60-Second Execution Timeout!
// If the human leaves the room completely for 60 seconds...
if (millis() - lastMotionTime > 60000) {
digitalWrite(relayPin, LOW); // Instantly sever the 220V High Voltage Grid! Lights OFF!
}
}
The Hardware Timeout Potentiometers
The HC-SR501 has two incredibly important orange trimpot screws on the physical circuit board!
- Sensitivity Trimpot: Adjusts the extreme biological detection range (approx 3 to 7 meters). If turned fully up, wind blowing on a warm curtain might falsely trigger the matrix!
- Time-Delay Trimpot: The hardware chip natively holds the pin
HIGHfor varying times (approx 3 seconds up to 5 minutes) completely independent of the Arduino code! - You MUST turn the Time-Delay Potentiometer entirely completely to the absolute Minimum (Left) so the Arduino utilizes
millis()programming for ultimate control instead of the dumb hardware chip!
Domestic Hardware Loadout Required
- Arduino Nano (Its tiny stature allows embedding directly into existing household ceiling light fittings effortlessly).
- HC-SR501 PIR Motion Sensor Module (Ensure its optical dome is mounted fully exposed to the immediate room, completely free of glass barriers, as glass entirely blocks infrared thermal radiation!).
- 5V Opto-Isolated Single Channel Relay Module (Crucially isolating the terrifying 110V/220V AC Grid from destroying the 5V
ATmegaLogic board natively!). - Standard Jumper wires and 5V USB AC adapter (To permanently supply stable grid-power offline into the Nano architecture 24/7).