Have you wonder about how disco light works, at every beat light changes its colour. You can see in market there are lots of product sound activated party light available from 13$ to 50+ $. It will be great if we can make our own sound activated party light which changes it colours according to music beats. In this tutorial we will control 12V RGB LED strip and make it music reactive party light. So lets get started.

For making this project you will need,

  1. Arduino,
  2. Sound Detection Module,
  3. 2.2k ohms resister,
  4. Breadboard,
  5. Jumper Wire,
  6. Transistor (TIP 122), 3 Qty
  7. 12V RGB LED light
Circuit Diagram:

Do connection as shown in diagram.

RGB party LED light Circuit diagram with arduino

I am using TIP122 for controlling from 5v to 12v. if you don’t how to use it or want to know how to calculate resistance for TIP122 you can see my previous tutorial control 12V LED or Fan from 5V with Arduino. I have already calculated base current resistance, so I am using 2.2K ohms resistance.

Sketch for sound activated 12V RGB party light:
int soundPin = A0;
int Red_LED = 9;
int Green_LED = 10;
int Blue_LED = 11;

void setup()
{
Serial.begin(9600);
pinMode(Red_LED, OUTPUT);
pinMode(Green_LED, OUTPUT);
pinMode(Blue_LED, OUTPUT);
}

void loop()
{
long sum = 0;
for(int i=0; i<100; i++)
{
sum += analogRead(soundPin);
}
sum = sum/100;

Serial.println(sum);

sum = map(sum, 50, 1000, 0, 255);

if (sum <= 50){
analogWrite(Red_LED, 0);
analogWrite(Green_LED, 0);
analogWrite(Blue_LED, sum);}
else if (sum < 100 && sum > 50){
analogWrite(Red_LED, 0);
analogWrite(Green_LED, sum);
analogWrite(Blue_LED, sum);}
else if (sum < 150 && sum > 100){
analogWrite(Red_LED, 0);
analogWrite(Green_LED, sum);
analogWrite(Blue_LED, 0);}
else if (sum < 200 && sum > 150){
analogWrite(Red_LED, sum);
analogWrite(Green_LED, sum);
analogWrite(Blue_LED, 0);} 
else if (sum < 250 && sum > 150){
analogWrite(Red_LED, sum);
analogWrite(Green_LED, 0);
analogWrite(Blue_LED, 0);} 
delay(10); 
}
Code Explanation:

Define sound pin, Green LED pin, Red LED pin and Blue LED pins.

int soundPin = A0;
int Red_LED = 9;
int Green_LED = 10;
int Blue_LED = 11;

Define output for Green, Red and Blue LED.

pinMode(Red_LED, OUTPUT);
pinMode(Green_LED, OUTPUT);
pinMode(Blue_LED, OUTPUT);

We are taking 100 sample of sound values. So that our inputs are much more accurate.

long sum = 0;
for(int i=0; i<100; i++)
{
sum += analogRead(soundPin);
}

Now we are averaging sample by dividing it by 100.

sum = sum/100;

We are printing values average value to serial monitor so that we can see what is input from our sound detection sensor. It is very useful in determining low and high sound values. Which we will be using in below code.

Serial.println(sum);

Now we are using map function it will map sound sensor values to voltage value output. Here we are taking sound values based on experimental output. i.e 50 to 1000. How we got this values? First upload the code. Open serial monitor, observe values when song were playing some song in front of sensor and values without song.

Find low and high values for sound sensor

You will get your low and high values. (but it should be between 0 to 1023 check your values.).

here i am not taking it from 0 because even if your room is at pin drop silence it will have some noises. Sound sensor values will be map to the voltage. 0 means 0V and 255 means 5V.

sum = map(sum, 50, 1000, 0, 255);

Here we are using if condition, if sum value i.e voltage output after map function. which will be going from 0 to 255. RGB LED will changes colours according to voltage. You can play with this setting to find your best party light.

if (sum <= 50){
analogWrite(Red_LED, 0);
analogWrite(Green_LED, 0);
analogWrite(Blue_LED, sum);}
else if (sum < 100 && sum > 50){
analogWrite(Red_LED, 0);
analogWrite(Green_LED, sum);
analogWrite(Blue_LED, sum);}
else if (sum < 150 && sum > 100){
analogWrite(Red_LED, 0);
analogWrite(Green_LED, sum);
analogWrite(Blue_LED, 0);}
else if (sum < 200 && sum > 150){
analogWrite(Red_LED, sum);
analogWrite(Green_LED, sum);
analogWrite(Blue_LED, 0);}
else if (sum < 250 && sum > 150){
analogWrite(Red_LED, sum);
analogWrite(Green_LED, 0);
analogWrite(Blue_LED, 0);}

So you have made your own Arduino sound activated party light with 12V RGB LED. Make sure you subscribe to my YouTube channel.

Till then keep learning, keep making.