DIY Arduino Projects: Smart Lighting and Infrared Sensor Lights with Uno

This post introduces two DIY Arduino projects: Cascading LED Stair Lights that illuminate stairs when approached, enhancing safety, and Infrared Sensor Lights that activate based on ambient light. Each project includes a list of components, circuit diagrams, sample code, and step-by-step instructions, making it easy for beginners to enhance their home automation skills and creativity.


Home automation is changing the way we interact with our homes. Using a affordable microcontroller such as an Arduino Uno, you can create a smart lighting system which improves safety and convenience in and around the house.

Today we are going to show you how to do two different home automation projects. The first project I’m going to go over is how to make some LED Stair Lights that turn on and off while you walk up and down the stairs (Cascading LED Stair Lights). The second project we will go over is how to make an Infrared Sensor Lightsthat turn on based on the ambient light conditions.

Each project will come with a comprehensive list of required components, step-by-step instructions, and sample code to help you get started. Every required components mentioned in this article will be fairly affordable to source online and can also be purchased from us.

Table of Content

1. Introduction to Home Automation

Home automation helps you control different systems in your home remotely or automatically. Using the Arduino, you can create your own home automation system. One of the easiest and useful applications of home automation is smart lighting, as it is not only easy to implement but also saves electricity, since all the lights are turned on and off for your convenience as the room occupancy changes.

2. Project 1: Cascading LED Stair Lights

Cascading LED Stair Lights is a fantastic and practical project to play with. It is also really nice to have lights automatically illuminate your stairs so you can see where you’re going. In particular, it becomes handy if you have kids who wake up during the night and walk around the house. This project uses an Arduino Uno to control a series of LEDs that illuminate one by one as soon as you walk towards the stairs as a cascading effect.

Components Required

  • Arduino Uno: The main controller.
  • LEDs: 5-10 bright white or colored LEDs.
  • Resistors: 220-ohm resistors for each LED.
  • Breadboard: For easy circuit connections.
  • Jumper Wires: For making connections.
  • PIR Motion Sensor: To detect movement.
  • Power Supply: USB or battery pack for Arduino.

Circuit Diagram of Cascading LED Stair Lights

Here’s the basic circuit diagram for connecting the LEDs and PIR sensor to the Arduino Uno:

       +5V  ───────────────────────────────────────────┐
│
+---+---+
|       |
[LED1]  [LED2]
|       |
+---+---+
│
Resistor
│
└───────── Arduino Pin 2 (for LED1)
│
+5V  ───────────────────────────────────────────┐
│
+---+---+
|       |
[LED3]  [LED4]
|       |
+---+---+
│
Resistor
│
└───────── Arduino Pin 3 (for LED3)
│
+5V  ───────────────────────────────────────────┐
│
+---+---+
|       |
[LED5]  [LED6]
|       |
+---+---+
│
Resistor
│
└───────── Arduino Pin 4 (for LED5)
│  
┌───────── PIR Sensor OUT ─────── Arduino Pin 7
│  
GND ────────────────────────────── GND

Code Required

Here’s a simple code snippet to control the cascading LED lights based on motion detected by the PIR sensor:

Version 1

Code Explanation For V1

Loop Function: The loop() function reads the PIR sensor value. If it detects motion (HIGH), it sequentially turns on each LED with a delay of 500 milliseconds between each, then keeps them on for an additional 2 seconds before turning them off.

Pin Definitions: You need to correctly define the pins for the LEDs and the PIR sensor.

Setup: The setup() function correctly sets the LED pins as outputs and the PIR sensor pin as input.

Version 2

This version allows for more flexibility and responsiveness to changes in the PIR sensor state.

Code Explanation For V2

  1. Avoid Blocking Code: Using delay() can block other code from running. Consider using a non-blocking approach with millis() if you want to add more functionality in the future.
  2. PIR Sensor Behavior: Depending on your PIR sensor, you might want to add some logic to handle multiple triggers or debounce the signal.

You may use any version or try both version and see the difference to learn.

Step-by-Step Guide

  1. Set Up Your Components: Gather all the required components and set them up on a breadboard.
  2. Connect the PIR Sensor: Connect the PIR sensor to the Arduino Uno. Connect its OUT pin to pin 7 on the Arduino.
  3. Connect the LEDs: Connect each LED through a resistor to pins 2, 3, and 4 on the Arduino.
  4. Upload the Code: Use the Arduino IDE to upload the provided code to your Arduino Uno.
  5. Test Your Project: Move in front of the PIR sensor and watch as the LEDs light up in sequence.

3. Project 2: Infrared Sensor Like Lights Using Light Dependent Resistor

Infrared sensor lights are another excellent home automation project that activates lights based on ambient light conditions. This project uses an LDR (Light Dependent Resistor) to turn on LEDs when it gets dark.

Components Required

  • Arduino Uno
  • LDR (Light Dependent Resistor)
  • Resistor: 10k-ohm resistor for LDR.
  • LEDs: Your choice of color.
  • Resistors: 220-ohm resistors for LEDs.
  • Breadboard
  • Jumper Wires
  • Power Supply

Circuit Diagram of Infrared Sensor Lights

Here’s how to connect an LDR and LED to the Arduino:

       +5V ───────────────────────────────┐
│
+--------+---------+
|                  |
[LDR]                |
|                  |
+----+----+             |
|         |             |
GND      Resistor         |
(10k)             |
|                |
+----------------+
|
└───────────── Arduino Pin A0 (LDR)
+5V ───────────────────────┐
│ 
+----+----+
|         |
[LED]     [LED]
|         |
+----+----+
|
Resistor 
|
└───────────── Arduino Pin 9 (for LED)

Code Required

This code reads the value from the LDR and turns on the LED when it gets dark:

Code Explanation

  1. Definitions:
    • #define LDR_PIN A0: This sets LDR_PIN to refer to the analogue pin A0 where the LDR is connected.
    • #define LED_PIN 9: This sets LED_PIN to refer to digital pin 9 where the LED is connected.
  2. Setup Function:
    • void setup(): This function runs once when the Arduino starts.
    • pinMode(LED_PIN, OUTPUT): This configures the specified LED pin as an output pin so it can control the LED.
  3. Loop Function:
    • void loop(): This function runs continuously after the setup.
    • int ldrValue = analogRead(LDR_PIN): This reads the analog value from the LDR. The value will be between 0 and 1023, where lower values indicate less light (more darkness).
    • The if statement checks if ldrValue is less than 200. This is a threshold that you can adjust based on your environment:
      • If ldrValue < 200: It means it’s dark enough, so the LED is turned on (digitalWrite(LED_PIN, HIGH)).
      • Otherwise, if the light level is above that threshold, the LED is turned off (digitalWrite(LED_PIN, LOW)).

Step-by-Step Guide

  1. Gather Components: Collect all necessary components for this project.
  2. Build Your Circuit: Set up your circuit on a breadboard according to the diagram.
  3. Upload the Code: Open your Arduino IDE and upload the code provided above.
  4. Test Your Setup: Cover the LDR with your hand or a dark object to simulate darkness and see if the LED lights up.

4. Conclusion

Creating DIY home automation projects like cascading LED stair lights and infrared sensor lights is a rewarding experience that enhances your living space’s safety and convenience. With just a few components and some coding, you can transform your home into a smarter place. These projects not only provide practical solutions but also spark creativity and encourage learning about electronics and programming. Hope this article adds a value to your knowledge.

Share your love

Leave a Reply