Published November 10, 2025 © GPL3+
A smart Arduino-powered system that senses darkness with an LDR and automatically switches an LED strip ON or OFF for hands-free lighting.
BeginnerFull instructions provided1 hour**1
Things used in this project
Hardware components
| Arduino UNO Mini |
×1 ](https://hackster.imgix.net/uploads/image/file/44496/11026-02.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)
| Jumper wires (generic) |
×1

| LDR, 5 Mohm |
×1

| Resistor 10k ohm |
×1
×1
| LED Strip 12v |
×1
Software apps and online services

Hand tools and fabrication machines

| Hot glue gun (generic) |
Story
This project creates an automatic light ON/OFF system using an LDR, a relay module, and an Arduino UNO Mini. When the environment becomes dark, the system turns an LED strip ON automatically. When enough light returns, it switches the strip OFF again. This is a clean, simple, beginner-friendly automation build that teaches light sensing, voltage dividers, and relay control.
Supplies Required
- Arduino UNO Mini: A smaller, more compact version of the classic Arduino UNO. It acts as the brain of the project. It reads the light level from the LDR makes decision based on the code you upload, and controls the relay. Runs on a 5v microcontroller (ATmega328P) and connects to your computer via USB.
- LDR ( Light Dependent Resistor ): A special type of resistor whose resistance changes with light. Bright light - low resistance Darkness - high resistance By reading this change through an analog pin, the Arduino can tell how bright or dark the environment is. This is the main sensor of the project.
- 10k Resistor: Used with the LDR create a voltage divider. This converts the changing resistance of the LDR into a changing voltage, which the Arduino can measure. The 10k value is ideal for typical indoor lighting conditions.
- Relay Module (5v): A small electrically operated switch. It allows the Arduino (low power 5v signal) controls something that draws much more power like a 12 v LED strip. It provides electrical isolation keeping the Arduino safe. The relay switch ON when the Arduino signals it and OFF when the signal stops.
- LED Strip (12 V): The lighting output of the project. When the relay turns ON, the LED strip receives power from the 12V adapter and lights up. When the relay turns OFF, the power is cut, and the strip turns off automatically.
- 12v Power Adapter: Supplies the necessary power for the LED strip. The Arduino cannot power the LED strip directly, so the adapter provides a separate power source that the relay controls. Provides a stable DC voltage for safe and consistent lighting.
- Jumper Wires: Flexible wires used to connect components on the breadboard. They link the the LDR circuit to the Arduino and connect the relay to the digital pins and power rails.
Software Description
Arduino IDE: The Arduino Integrated Development Environment (IDE) is the software used to write, edit, and upload code to the Arduino board.
Features include:
- A simple code editor for writing sketches
- One-click Verify and Upload buttons
- A Serial Monitor that shows sensor readings from the board
- Built-in libraries and examples
- Support for thousands of Arduino-compatible boards.
The IDE converts your code into machine instructions and sends it to the Arduino UNO Mini through the USB cable. It is beginner-friendly and perfect for learning programming and electronics.
Steps To Build
Wiring the LDR SensorCreate a voltage divider
- LDR leg1 - 5v
- LDR leg 2 - A0
- 10k resistor between A0 and GND
This setup gives the Arduino a changing voltage that represents brightness.
Wiring the Relay Module
- Relay VCC - 5v
- Relay GND - GND
- Relay IN - Digital Pin 2
LEDStripPower
For a 12v LED Strip:
- LED strip + directly to 12V supply
- LED strip - to COM on relay
- Relay NO to the 12v supply ground
The relay will switch the strip ON/OFF by controlling the ground connection.
Uploading The Code
Use the Arduino IDEThe sketch below reads the LDR, checks if it’s dark, and switches the relay.
// Beginner-friendly: Read button on pin 6 and control a relay on pin 2// Wiring (recommended):// - Relay module VCC -> 5V// - Relay module GND -> GND// - Relay module IN -> Arduino digital pin 2// - Button one side -> Arduino pin 6// - Button other side -> GND// Note: This sketch uses INPUT_PULLUP, so button connects to GND when pressed.const int RELAY_PIN = 2; // Relay control pinconst int BUTTON_PIN = 7; // Input pin (button or switch)// If your relay module is "active LOW" (common for many modules), set true.// If your relay turns ON when IN is HIGH, set false.const bool RELAY_ACTIVE_LOW = false;void setup() {Serial.begin(9600); // Optional: debug output to Serial MonitorpinMode(RELAY_PIN, OUTPUT); // Relay pin is an outputpinMode(BUTTON_PIN, INPUT_PULLUP); // Use the internal pull-up resistor// Make sure relay starts OFFif (RELAY_ACTIVE_LOW) digitalWrite(RELAY_PIN, HIGH); // HIGH -> off for active-low relayelse digitalWrite(RELAY_PIN, LOW); // LOW -> off for active-high relaySerial.println("Ready. Press the button to turn the relay ON.");}//Made By Rohan Barnwalvoid loop() {// Read the button. Because of INPUT_PULLUP, pressed == LOW.int raw = digitalRead(BUTTON_PIN);bool pressed = (raw == LOW); // true when button is pressed// Simple debounce: when we detect a press state change, wait briefly and re-read.static bool lastPressed = false;if (pressed != lastPressed) {delay(30); // small debounce delay (30 ms)raw = digitalRead(BUTTON_PIN);pressed = (raw == LOW);lastPressed = pressed;}// Turn relay on or off based on buttonif (pressed) {// Turn relay ONif (RELAY_ACTIVE_LOW) digitalWrite(RELAY_PIN, LOW); // active-low -> LOW turns ONelse digitalWrite(RELAY_PIN, HIGH); // active-high -> HIGH turns ONSerial.println("Relay: ON");} else {// Turn relay OFFif (RELAY_ACTIVE_LOW) digitalWrite(RELAY_PIN, HIGH); // active-low -> HIGH turns OFFelse digitalWrite(RELAY_PIN, LOW); // active-high -> LOW turns OFFSerial.println("Relay: OFF");}delay(100); // small loop delay to avoid flooding Serial}
Testing
- Cover the LDR with your hands - LED strip should turn ON
- Shine a light - LED strip should turn OFF
Taking It to the Next Level - With JUSTWAY
Your breadboard prototype may work perfectly, but looks like a tech spaghetti bowl.
When you want to impress at a science fair, competition, or investor meeting presentation is everything.
That’s where JUSTWAY comes in.
JUSTWAY helps you transform your DIY project into a professional grade prototype, complete with a custom enclosure, metal finish, or injection-molded body - ready for the world to see.
Why JUSTWAY is the Perfect Partner
- Rapid Prototyping: 24-hour turnaround, real time order tracking
- CNC Machining: Aluminum 6061 or Stainless Steel 304 - strong, premium enclosures
- Sheet Metal Fabrication: Laser-cut CNC-bent and powder coated finishes
- Injection Molding: Ideal for moving from prototype to mass production
- Urethane Casting: Perfect for small batches or display models
- 3D Printing (SLA / HP-PA12): SLA resin for clear aesthetic display, HP-PA12 nylon for durable, matte finish
Pro Tip: Want your circuit look futuristic?
- Use transparent SLA resin to show off your Arduino and LEDs
- Or go matte black HP-PA12 for a stealthy, modern vibe.
How To Order in 4 Easy Steps
Step1: Upload You CAD Files at JUSTWAY.com
Step2: Select Material & Finish - plastics, resins or metals
Step 3: Preview Your Model in 3D - Check fit and look before confirming
Step 4: Place Your Order - Fast Delivery, Transparent Pricing, Zero Hidden Costs.
Conclusion
You now have a simple and reliable automatic lighting controller using an LDR, relay, and Arduino UNO Mini. This system is great for bedrooms, hallways, stair lighting, or outdoor decorative LEDs. By combining this with a 3D-printed housing from JUSTWAY, you can turn a hobby build into a neat, durable, professional-looking device.
**Read more
Schematics
