Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Techatronic
Published

LED VU-meter Music Reactive Light

VU- meter using Arduino and sound sensor

BeginnerFull instructions provided1 hour340
LED VU-meter Music Reactive Light

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Gravity: Analog Sound Sensor For Arduino
DFRobot Gravity: Analog Sound Sensor For Arduino
×1
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

led vu meter

Code

code

C/C++
#include "BluetoothSerial.h"

/* Check if Bluetooth configurations are enabled in the SDK */
/* If not, then you have to recompile the SDK */
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;




void setup() {
  // put your setup code here, to run once:
pinMode(A6, INPUT_PULLUP);
pinMode(A7, INPUT_PULLUP);
pinMode(15, OUTPUT);
pinMode(16, OUTPUT);
pinMode(17, OUTPUT);
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);
pinMode(21, OUTPUT);
pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(25, OUTPUT);
pinMode(26, OUTPUT);
Serial.begin(115200);
SerialBT.begin();
digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
delay(20);
}

void loop() {





    if (SerialBT.available()>0)
  {
char m = SerialBT.read();
    
    Serial.println(m);



switch (m)
  
{




case 'A': //BLINK

while(1)


{

  
  // put your main code here, to run repeatedly:
int music = analogRead(A6);
int pot = analogRead(A7);
int intensity = map(pot, 0 , 4095 , 0, 1500);
 Serial.print(music);
  Serial.print("      ");
 Serial.println(intensity);
 // delay(50);


if(SerialBT.available()>0)
{  
break; }




if( music >= 2600-intensity && music <= 2850+intensity)

{
  
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);
delay(50);
  
  }


else 
{
  
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
delay(50);
  
  
  }





}

/////


case 'B': //BLINK

while(1)


{
if(SerialBT.available()>0)
{  
break; }
  
  // put your main code here, to run repeatedly:
int music = analogRead(A6);
int pot = analogRead(A7);
int intensity = map(pot, 0 , 4095 , 0, 2000);
 Serial.print(music);
  Serial.print("      ");
 Serial.println(intensity);

int z = -(music-2700);

int c = map(z, 0 , 1000+intensity, 14, 26);
Serial.println(c);

if(c==15)
{
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);


delay(30);
  digitalWrite(15, HIGH);

delay(50);
}


else if(c==16)
{
 digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
delay(50);
}




else if(c==17)
{
 digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);
delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
delay(50);

}

else if(c==18)
{
 digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);
delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
delay(50);
}

if(SerialBT.available()>0)
{  
break; }
else if(c==19)
{
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
delay(50);
}

else if(c==21)
{
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
delay(50);
}



else if(c==22)
{
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
delay(50);
}

else if(c==23)
{
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
delay(50);
}




else if(c==25)
{
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
digitalWrite(25, HIGH);
delay(50);
}



else if(c==26)
{
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(30);
  digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
delay(50);
}
else
{
  
  digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(50);
  }


}







case 'C': //BLINK

while(1)


{
if(SerialBT.available()>0)
{  
break; }
digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
delay(50);
}


case 'D': //BLINK

while(1)


{
if(SerialBT.available()>0)
{  
break; }
digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(50);
}




case 'E': //BLINK

while(1)


{

  int pot = analogRead(A7);
int intensity = map(pot, 0 , 4095 , 0, 1500);

if(SerialBT.available()>0)
{  
break; }


digitalWrite(15, LOW);
digitalWrite(16, LOW);
digitalWrite(17, LOW);
digitalWrite(18, LOW);
digitalWrite(19, LOW);
digitalWrite(21, LOW);
digitalWrite(22, LOW);
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(26, LOW);

delay(intensity);

digitalWrite(15, HIGH);
digitalWrite(16, HIGH);
digitalWrite(17, HIGH);
digitalWrite(18, HIGH);
digitalWrite(19, HIGH);
digitalWrite(21, HIGH);
digitalWrite(22, HIGH);
digitalWrite(23, HIGH);
digitalWrite(25, HIGH);
digitalWrite(26, HIGH);
delay(intensity);
}

////
  
  
}

  }
}

Credits

Techatronic

Techatronic

72 projects • 127 followers
Electronic engineer

Comments