Automatic dusk-to-dawn light
Lights switch on by themselves at dusk and off again in the morning.
Shop by category
Shop all componentsThis light combines three ways of control. A mini PIR sensor turns it on when it sees movement. An IR receiver lets a cheap remote choose always-on, auto or off. A PAJ7620 gesture sensor reads a hand wave up or down to change the brightness. The Nano drives a strip of LEDs through a relay module, or a 12 V LED strip if you use a MOSFET.
Use 12 V LED lighting while learning; mains wiring is for qualified electricians only.
Tick anything you already have and the total updates.
HC-SR505 mini PIR motion sensor
38 kHz TSOP1838 IR receiver module
PAJ7620U2 gesture sensor, I2C
BISS0001 PIR controller IC for building your own PIR board
Bare pyroelectric element to pair with the BISS0001
Larger PIR module with a longer range
Touch pad as a fourth way to switch the light
Ready-made 12 V touch dimmer switch for mirror lights
All-in-one IR remote relay if you do not want to program anything
Follow the colours: red is power, dark grey is ground, blue is a signal.
motion_light.inoVerify & upload in Electrolark#include <IRremote.hpp>
#include <RevEng_PAJ7620.h>
RevEng_PAJ7620 gesture;
const int PIR = 2, IR_PIN = 11, RELAY = 7;
const uint8_t CMD_ON = 0x45, CMD_AUTO = 0x46, CMD_OFF = 0x47; // replace with your remote's codes
enum Mode { AUTO, ON, OFF } mode = AUTO;
unsigned long lastMotion = 0;
const unsigned long HOLD = 30000UL;
void setup() {
Serial.begin(115200);
pinMode(PIR, INPUT); pinMode(RELAY, OUTPUT);
IrReceiver.begin(IR_PIN, ENABLE_LED_FEEDBACK);
if (!gesture.begin()) Serial.println("Gesture sensor not found");
}
void loop() {
if (IrReceiver.decode()) {
uint8_t c = IrReceiver.decodedIRData.command;
Serial.print("IR command 0x"); Serial.println(c, HEX);
if (c == CMD_ON) mode = ON; else if (c == CMD_AUTO) mode = AUTO; else if (c == CMD_OFF) mode = OFF;
IrReceiver.resume();
}
Gesture g = gesture.readGesture();
if (g == GES_UP) mode = ON;
if (g == GES_DOWN) mode = OFF;
if (g == GES_CLOCKWISE) mode = AUTO;
if (digitalRead(PIR) == HIGH) lastMotion = millis();
bool on = mode == ON || (mode == AUTO && millis() - lastMotion < HOLD);
digitalWrite(RELAY, on ? HIGH : LOW);
delay(20);
}
The sketch above runs here on a simulated Arduino Nano. Move the sliders for the sensors and buttons it reads, and watch the Serial monitor, display and outputs change.
PIRs react to warm air; move it away from heaters, fans and windows.
Check the command numbers in the Serial Monitor; every remote is different.
Check SDA/SCL and the supply voltage; the PAJ7620 address is 0x73.
Only inside a closed, earthed enclosure installed by a qualified electrician. Use a 12 V LED lamp for learning.
PIR sensors settle for up to a minute before they detect reliably.
Most remotes work with IRremote; the codes just differ.
14 parts: Nano CH340 Development Board (Soldered), HC-SR505 Mini PIR Motion Sensor Infrared Detector Module, Generic Infrared IR Receiver Module for Arduino – 38kHz TSOP1838 Sensor, Generic IR Remote Control (21-Button, CR2025), PAJ7620U2 Gesture Recognition Sensor Module – I2C Interface, 3.3V/5V, 5V Relay Module with Optocoupler, GR BISS0001 Infrared Pyroelectric Human Body Sensing Sensor Controller SOP-16, Senba D203B TO-5-3 Human Body Sensing Sensor ROHS, Senba D204B Active PIR Motion Sensor with EMI Pyroelectric Infrared Detector, HS-S43A Touch Sensing Sensor Module – PH2.0 Terminal, Switch/Button Mode, plus 4 more. On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 2 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (motion_light.ino).
Yes. The Run it panel under the code runs this exact sketch on a simulated board. Move the sliders or press the buttons for the sensors it reads, and the Serial monitor, display and outputs react as they will on the real build. It is a simulation, so real readings depend on your parts and wiring.
About ₹1,735 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
How PIR motion sensors work; Decoding NEC IR remotes; Reading a gesture sensor over I2C.
Ideas that reuse this build: BLE beacon presence light. They are listed under Take it further on this page.
Lights switch on by themselves at dusk and off again in the morning.
A precise thermostat that keeps tropical fish at a steady 25–26 °C.
Starts the pump when the tank runs low and stops it when it is full.
Tap a hidden pad to switch a lamp on or off, even through a wooden desk.
Learning project. Check every circuit and the datasheet of each part before you power it up.
A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.