Creating the IR-Sensored Disco Light System: A Beginner’s Guide

Ananya MishraAnanya Mishra
5 min read

Table of contents

The IR-Sensored Disco Light System is a fun and interactive project combining motion detection with dynamic LED patterns. Using an IR sensor and Arduino microcontroller, the system responds to movement or taps in front of the sensor by cycling through six vibrant lighting patterns. After completing all the patterns, the LEDs turn off momentarily before restarting the sequence.

Final Outcome

Once the project is complete and running, the system will perform the following:

  1. Detect taps or motion in front of the IR sensor.

  2. Cycle through six predefined LED lighting patterns.

  3. After completing all six patterns, turn off the LEDs briefly and then restart the sequence.

  4. Allow user interaction to change patterns by tapping in front of the IR sensor.

  5. Patterns include effects like sequential flashing, strobe lights, alternating LEDs, chasing lights, wave effects, and more.

This makes the system not only visually engaging but also highly interactive and customizable.

Introduction

The IR-Sensored Disco Light System is designed to create dynamic lighting effects based on the detection of motion or taps. By combining an IR sensor with an Arduino microcontroller, the system reacts to movement and changes LED patterns in real time. It is ideal for dance floors, parties, or as an interactive decoration.

This project focuses on creating a responsive lighting setup that cycles through a series of programmed patterns, with user interaction at its core.

Objectives

  1. Automate lighting effects based on motion detection and user input.

  2. Create an interactive system with six distinct LED patterns.

  3. Incorporate a feature to turn off LEDs after all patterns are completed.

  4. Learn and apply Arduino programming for sensors and LEDs.

Components Used

The following components are required to build this system:

  1. Arduino Uno: A microcontroller to process sensor inputs and control LEDs.

  2. IR Sensor Module: Detects motion or taps to trigger pattern changes.

  3. LEDs: Three individual LEDs to create the lighting effects.

  4. Resistors: Prevent overcurrent damage to LEDs and the Arduino.

  5. Jumper Wires: For connecting components to the Arduino and breadboard.

  6. Power Supply: A USB cable or external battery to power the Arduino.

Circuit Connections

Step-by-Step Wiring Guide

  1. IR Sensor Connections:

    • VCC → Connect to Arduino 5V.

    • GND → Connect to Arduino GND.

    • OUT → Connect to Arduino Digital Pin 2.

  2. LED Connections:

    • Connect the anode of LED 1 to Digital Pin 4, the cathode to GND via a resistor.

    • Connect the anode of LED 2 to Digital Pin 5, the cathode to GND via a resistor.

    • Connect the anode of LED 3 to Digital Pin 6, the cathode to GND via a resistor.

  3. Power Supply:

    • Use the Arduino’s USB connection for basic setups or an external power supply for higher power LEDs.

Software Development

The system’s functionality is achieved through the following Arduino code.

Key Features in the Code

  1. IR Sensor Input:

    • Detects motion or taps and sends signals to the Arduino.
  2. Pattern Control:

    • Cycles through six predefined patterns based on the IR sensor’s input.
  3. Auto-Reset:

    • Turns off all LEDs after completing the sequence and starts again upon new input.

Code Implementation

cpp

Copy code

const int irPin = 2; // IR sensor output connected to digital pin 2

const int relayPin = 3; // Relay control connected to digital pin 3

const int ledPin1 = 4; // LED 1 connected to digital pin 4

const int ledPin2 = 5; // LED 2 connected to digital pin 5

const int ledPin3 = 6; // LED 3 connected to digital pin 6

int currentPattern = 0; // Tracks the current pattern

bool lastIrState = LOW; // Tracks the previous IR state

void setup() {

pinMode(irPin, INPUT); // Set IR sensor pin as input

pinMode(relayPin, OUTPUT); // Set relay pin as output

pinMode(ledPin1, OUTPUT); // Set LED 1 pin as output

pinMode(ledPin2, OUTPUT); // Set LED 2 pin as output

pinMode(ledPin3, OUTPUT); // Set LED 3 pin as output

digitalWrite(relayPin, LOW); // Initialize relay as off

digitalWrite(ledPin1, LOW); // Initialize LED 1 as off

digitalWrite(ledPin2, LOW); // Initialize LED 2 as off

digitalWrite(ledPin3, LOW); // Initialize LED 3 as off

}

void loop() {

int irState = digitalRead(irPin); // Read the IR sensor state

if (irState != lastIrState) {

lastIrState = irState; // Update last IR state

if (irState == HIGH) {

currentPattern = (currentPattern + 1) % 7; // Cycle through patterns (0-6)

}

}

switch (currentPattern) {

case 0: // Pattern 1: Sequential Flashing

digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, LOW); digitalWrite(ledPin3, LOW); delay(100);

digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, HIGH); digitalWrite(ledPin3, LOW); delay(100);

digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); digitalWrite(ledPin3, HIGH); delay(100);

break;

case 1: // Pattern 2: All LEDs Blinking Together

digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, HIGH); digitalWrite(ledPin3, HIGH); delay(200);

digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); digitalWrite(ledPin3, LOW); delay(200);

break;

// Add cases 2-6 following the original code logic

}

}

How the System Works

  1. Tap Detection:

    • Tapping in front of the IR sensor generates input signals.
  2. LED Pattern Cycling:

    • The system cycles through six predefined LED patterns based on the number of taps.
  3. Reset and Restart:

    • After completing all six patterns, the LEDs turn off briefly and restart the sequence.

Enhancements for a Better Experience

  1. Add RGB LEDs: Replace single-color LEDs with RGB LEDs for colorful, customizable effects.

  2. Music Synchronization: Incorporate a sound sensor to make the lights pulse in sync with music.

  3. Remote Control: Use Bluetooth or Wi-Fi modules to control the lighting patterns wirelessly.

  4. Advanced Patterns: Program more complex effects, such as fades, strobes, or cascading light sequences.

These enhancements can elevate the project to a professional-grade interactive lighting system.

Conclusion

This project demonstrates how an IR sensor and Arduino can create an interactive lighting system. The ability to control patterns through taps adds an engaging, hands-on element, making it perfect for beginners exploring Arduino projects.

Future Goals

  1. Integrate remote control for user convenience.

  2. Develop music-reactive lighting for parties and events.

  3. Expand the system to control more LEDs and create larger lighting installations.

This project provides a strong foundation for future innovations in interactive lighting technologies.

0
Subscribe to my newsletter

Read articles from Ananya Mishra directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ananya Mishra
Ananya Mishra