Project Overview
The "Automated Motion-Sensing Switch" is a highly practical home automation project that provides hands-free control of electrical appliances. By interfacing a Passive Infrared (PIR) Sensor with an Arduino Nano, the project detects the infrared radiation emitted by moving human bodies and triggers a 5V Relay Module. This allows the system to switch high-voltage loads like hallway lights, bathroom fans, or alarm buzzers. It is an ideal entry point for learning about digital binary logic, relay isolation, and the physics of infrared detection.
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
******************************************************************************


Technical Engineering Depth
- PIR Sensor Physics (HC-SR501): The PIR sensor contains a pyroelectric material that generates an electric current when exposed to infrared heat. It is divided into two halves; motion is detected when a differential signal is generated as a person passes from the field of view of one half to the other.
- Hardware Calibration: The module features two onboard potentiometers:
- Sensitivity Adj: Controls the maximum distance the sensor can "see" (3m to 7m).
- Time Adj: Controls how long the signal stays HIGH after motion is detected (from 5 seconds to several minutes). This hardware-level timing is supplemented by software delays in the Arduino code.
- Relay Driver Mechanism: The Arduino Nano lacks the current required to physically move the mechanical armature of a relay. Therefore, the relay module includes a transistor-based driver circuit (typically using an 8050 or 2N2222) and a flyback diode to neutralize inductive spikes that could damage the microcontroller.
- PCB Prototyping: Transitioning from a breadboard to a permanent PCB allows the system to be safely enclosed in a project box. Proper soldering of the PIR sensor headers and the relay terminal blocks is essential for long-term vibration resistance.
- Logic Optimization: The code employs a simple
digitalRead()on the PIR output pin. WhenHIGH, it executes adigitalWrite(relayPin, HIGH). Advanced versions may include "L" (Single Trigger) or "H" (Repeat Trigger) modes, which can be configured via a jumper on the PIR sensor itself to change the re-triggering behavior.