Skip to content

Instantly share code, notes, and snippets.

@vkgupta857
Created February 19, 2022 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vkgupta857/31655723798bf7976857ecfa5ee74a23 to your computer and use it in GitHub Desktop.
Save vkgupta857/31655723798bf7976857ecfa5ee74a23 to your computer and use it in GitHub Desktop.
Create Disco light show setup using LEDs and Arduino UNO

Create Disco Light show setup using LEDs and Arduino UNO

Requirements

  • Arduino UNO Board
  • Arduino IDE (any version can be used, version 1.8 was used here)
  • LEDs (15 used here, any number can be used but total current limit of Arduino UNO is ~150mA)
  • Jumper Wires
  • Sound Sensor which has digital and analog out
  • Breadboard

Pin Setup

Arduino UNO pin Connected to
A0 Digital out (DO) of Sound Sensor
5V + of Sound Sensor
Ground (GND) besides 5V Ground (GND) of Sound Sensor
Ground (GND) besides 13 Common ground in breadboard
pin 2 to 13 and A3 to A5 (total 15 pins) +ve terminal of LEDs (-ve terminal of all connected to common ground of breadboard)

(more pins can be used for giving output as and when required)

Source Code

const int soundIn = A0;
const int ledA3 = A3;
const int ledA4 = A4;
const int ledA5 = A5;
const int led13 = 13;
const int led12 = 12;
const int led11 = 11;
const int led10 = 10;
const int led9 = 9;
const int led8 = 8;
const int led7 = 7;
const int led6 = 6;
const int led5 = 5;
const int led4 = 4;
const int led3 = 3;
const int led2 = 2;
const int led1 = 1;
const int led0 = 0;

void setup() {
  pinMode(soundIn, INPUT);
  pinMode(led13, OUTPUT);
  pinMode(led12, OUTPUT);
  pinMode(led11, OUTPUT);
  pinMode(led10, OUTPUT);
  pinMode(led9, OUTPUT);
  pinMode(led8, OUTPUT);
  pinMode(led7, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(ledA5, OUTPUT);
  pinMode(ledA4, OUTPUT);
  pinMode(ledA3, OUTPUT);
}

void loop() {
  int value = digitalRead(soundIn);
  if(value == HIGH) {
    digitalWrite(led2, HIGH);
    digitalWrite(led3, HIGH);
    digitalWrite(led4, HIGH);
    digitalWrite(led5, HIGH);
    digitalWrite(led6, HIGH);
    digitalWrite(led7, HIGH);
    digitalWrite(led8, HIGH);
    digitalWrite(led9, HIGH);
    digitalWrite(led10, HIGH);
    digitalWrite(led11, HIGH);
    digitalWrite(led12, HIGH);
    digitalWrite(led13, HIGH);
    digitalWrite(ledA5, HIGH);
    digitalWrite(ledA4, HIGH);
    digitalWrite(ledA3, HIGH);
  } else {
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    digitalWrite(led4, LOW);
    digitalWrite(led5, LOW);
    digitalWrite(led6, LOW);
    digitalWrite(led7, LOW);
    digitalWrite(led8, LOW);
    digitalWrite(led9, LOW);
    digitalWrite(led10, LOW);
    digitalWrite(led11, LOW);
    digitalWrite(led12, LOW);
    digitalWrite(led13, LOW);
    digitalWrite(ledA5, LOW);
    digitalWrite(ledA4, LOW);
    digitalWrite(ledA3, LOW);
  }
}

Steps

  • Arrange the pins according to the pin setup given above.
  • Adjust the code given above
  • Upload the code given above to Arduino UNO board using Arduino IDE.
  • Adjust the potentiometer of sound sensor according to you.
  • Play the sound and enjoy the music with Disco Lights (LEDs) ;).

About

I talk about softwares and some experiments with electronic gadgets. Liked the content above, you can buy me a coffee to appreciate the efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment