Party Lights

8,073

98

109

Published

Introduction: Party Lights

This project is dedicated to creating a music visualizer that picks up sound using a microphone and converts it into the blinking of an individually addressable LED strip. The LED strip is controlled by Arduino Uno (or pro mini) that is controlled via Bluetooth from an Android app (doesn't work for iPhones), which also allows you to set the color of the LEDs or launch a color animation.

Step 1: Components

  1. LED Strip WS2812B. There are a variety of places that sell these strips, I’d recommend Ebay (here) as it will save you money, but if you want a higher quality product, you can check out adafruit.com of sparkfun.com. There is a variety of length and densities available, you can choose anything that suits you, but more LEDs need more memory to control them and at some point Arduino will run out of it. 128 LEDs is a safe bet, but you can go a little higher if you wish to do so.
  2. Arduino Uno. You can buy one from the official vendor or from Ebay (here) for much-much cheaper. I bought mine for ~$5.
  3. Electret microphone combined with an amplifier MAX4466. Again, they sell those on Ebay (here) as well.
  4. Bluetooth adapter HC-06. I bought mine on Ebay (here).
  5. 5V power adapter for Adruino (optional as you can use USB) and the LED strip (required, unless your strip is very short and can be powered directly from Uno). Make sure your power supply can provide enough power at 5V for the whole LED strip. My 5m strip consumes ~45 W (e.g. I ~ 9 A) at maximum brightness. Ebay has those as well.
  6. A bunch of wires to connect things.
  7. Breadboard to connect everything through (choose your favorite size and color). This is optional as you can connect things directly to Arduino, but it will look messy, so I’d recommend doing it only after you’ve made everything work using the breadboard.
  8. Soldering iron and solder. Some vendors send components detached from their connecting pins, in which case you’ll have to solder them yourself.

Step 2: Configuring Bluetooth Adapter

Before you start building the music visualizer, you’ll need to configure the Bluetooth module so it uses the same baud rate as the final Arduino program. To do it, you will need to:

1. Download the archive and open test.ino in Arduino IDE. Upload the code to Arduino (there are plenty of tutorials that will show you how). It will allow you to communicate with the Bluetooth module and see its responses in the serial monitor.

2. Connect HC-06 to Arduino according to this diagram.

3. Open Serial monitor in your Arduino IDE (Tools -> Serial Monitor)

4. Make sure the baud rate is set to 9600. To enter a command, just type it in the monitor input and press enter.

5. You can find the list of possible commands to send in the attached pdf.

6. I’d recommend changing the name of the device to something that makes more sense (like “LED strip”) and you can also change the password if you want to protect your lights from any local LED pirates.

7. Once you’ve finished, there is one final setting you need to change. Type in “BAUD8” (no quotation marks) and make sure you receive “OK115200” from the module. Once it’s done, you won’t be able to send any more commands unless you change the baud rate to 115200 in the Arduino code.

8. You’re done! Disconnect HC-06 from Arduino.

Step 3: Assembling Everything Together

Once the Bluetooth module is configured, you can start assembling the final setup.

1. Make sure nothing is connected to the serial ports (digital pins 1 and 2) of your Arduino. Upload the attached code:

  • the folder LED_control contains the .ino file that you should open in Arduino IDE
  • the folder "FHT" inside "ArduinoFHT2" is the library you should attach to your Arduino project before compiling the code. This is a great library for doing the FHT transform (which is FFT for real numbers) I took from here, so you can also download it from their website. To install the library, go to Sketch -> Include Library -> Add .ZIP library, then navigate to the folder "FHT" and click open. This is counter-intuitive since you are adding a folder, not a .zip, but that's the right way to do it.
  • once the library is connected, you can upload the code.

2. Connect all the elements according to the schematic. The schematic uses one power supply for both arduino and the LED strip, but you can power them separately (for example, arduino can be powered via USB and the strip – through a power adapter). If you decide to do so, make sure to CONNECT ARDUINO GROUND AND THE LED GROUND. If you don’t do so, your strip won’t work.

3. Install this android app (the .apk file) on your phone.

4. Launch the app and connect to your Bluetooth module.

5. Set the number of LEDs you have connected to Arduino and press “SEND”.

5. Try to send some colors to the LED strip. If it works, you’re done!

6. P.S.: before you launch music visualization, it’s useful to record the noise level (there is a corresponding button in the app). If your lights blink when there is no sound, you can re-record the noise for a longer duration (for me 3 s works fine, but it really depends on your power supply quality and the surrounding electromagnetic noise)

Step 4: P.S.

If you made everything work, it might be a good time to put everything in a nice box. It was easy for as I have access to a laser cutter so I just made one out of acrylic sheet.

Additionally, if you want to make this device much smaller, good news, you can! To do so, you should use Arduino pro mini (the 5V, 16MHz version), which you can buy on Ebay for ~$3. Assembling everything would require some soldering, as there are no pin connectors on the mini. Additionaly, you’ll need a serial-to-USB converter. Be careful when you buy those as not all of them have all the required channels to work with Arduino. The easiest way to make sure it will work is to buy both Arduino and the converter in a pack on Ebay. Or you can buy the official converter from the Arduino website if you’d like to spend more money. Finally, you will need a voltage regulator that can convert 5V to 3.3V as Arduino pro mini doesn’t have a 3.3V power supply you need for the microphone.

The assembly procedure is very similar. The only difference is that you’ll need to make a switch that allows you to disconnect the Bluetooth module from ports 1-2 and connect them to the ports 10-11 for programming. If you don’t do it, you won’t be able to upload any code to arduino or reprogram the Bluetooth adapter in the future.

2 People Made This Project!

Recommendations

  • Water Contest

    Water Contest
  • Creative Misuse Contest

    Creative Misuse Contest
  • Oil Contest

    Oil Contest

109 Discussions

hey man, I hope you still read these comments. I have been trying to replace the mic with an aux plug, so i can connect it to my phone, and have the audio be a little more accurate and less delayed. the internet won't give me a simple answer, maybe because there is none - but my question: is it possible to replace the mic with an aux plug, and if yes, do I need to change your code for it, and how would I connect said plug? cheers!

I have tried to install the library as per your instructions but on compiling i get the following error

Arduino: 1.8.2 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\SUPERU~1\AppData\Local\Temp\cc4yfVLM.ltrans1.ltrans.o: In function `fht_window() [clone .lto_priv.44]':

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:1248: undefined reference to `_window_func'

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:1248: undefined reference to `_window_func'

C:\Users\SUPERU~1\AppData\Local\Temp\cc4yfVLM.ltrans1.ltrans.o: In function `fht_mag_log() [clone .lto_priv.41]':

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:832: undefined reference to `fht_log_out'

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:832: undefined reference to `fht_log_out'

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:832: undefined reference to `_log_table'

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:832: undefined reference to `_log_table'

C:\Users\SUPERU~1\AppData\Local\Temp\cc4yfVLM.ltrans1.ltrans.o: In function `fht_reorder() [clone .lto_priv.43]':

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:681: undefined reference to `_reorder_table'

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:681: undefined reference to `_reorder_table'

C:\Users\SUPERU~1\AppData\Local\Temp\cc4yfVLM.ltrans1.ltrans.o: In function `fht_run() [clone .lto_priv.42]':

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:603: undefined reference to `_cas_constants'

C:\Users\SuperUserockx\Documents\Arduino\libraries\FHT/FHT.h:603: undefined reference to `_cas_constants'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino/Genuino Uno.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

While everything works fine, when I put the sound visualizer, the led strip lights at random times, no matter what the sound is, I guess the max4466 picks random noise but I can't overcome this, even if I change the record noise level, any suggestions?

Question, how would I use an auxillary jack for my source of sound? I know that you can hook it up through the breadboard, and I also do not intend to make my Arduino into an enclosed system, I'm going to continue to use the breadboard. Another thing, how would I power the LED strips with the 5v if I can power the Arduino with the USB? If you don't mind could you email me and we can have a discussion about this? I am trying to make my LEDs react to bass, for a setup under a coffee table. If you can get back to me as soon as you can that would be very much appreciated :)

0
user
Noro13

1 year ago

How can I send the commands into the serial monitor. I connected the
arduino uploaded the code then opened the serial monitor and the ascii
table - character map list pop-up, but when i add a command nothing
happens.

Even when i type BAUD8 I dont receive any respond from the arduino.

12 replies

please see my reply to a similar question above and let me know if it helps.

My HC-06 is blinking red and blue, and I can pair it using my phone.

TXD connected to pin 10 and RXD to the 11pin. And all the rest are connected correctly (checked few times).

Also
tried to restart the monitor and re-plugging arduino to usb several
times, but nothing change, and still the module doesnt respond to any
commands.

And I cant see "Send AT commands" in the monitor the only thing I can see is the below (ASCII Table ~ Character Map) and this is it.

achci.jpg

I can connect to HC06 with my phone using bluetooth terminal (then the lights on HC06 become solid).

Also when I input any command in the serial monitor and press enter an orange led on arduino blinks once but still no response.

this is quite weird, I don't know what you did, but there shouldn't be any tables in the monitor. The only thing I can think of is that your arduino is not running the code it's supposed to. Try re-uploading the code in test.ino and make sure it goes through.

I have re-upload the code of test.ino many times and still nothing change. Aldo re-downloaded it from the site in case that you could change something but still no response. Also I spent all day searching on the web for similar problem but couldn't find any answer(s).

[About you diagram in step 2 - is says that RXD goes to Digi10 and TXD goes to Digi11, but how it is connected on the picture is the opposite, could you change it, because it is a bit confusing.]

Huh, you're right, there is an error there. The connection diagram is correct, but the writing is wrong. I'll fix it momentarily

According to my problem, there is any tip/help that you could give me so I could fix my problem or it isnt and I can throw away the parts I bought?

I just googled what you see in the monitor and it seems like your arduino is running an example code for printing ASCII table from this tutorial: https://www.arduino.cc/en/Tutorial/ASCIITable

So, the problem is that you still haven't uploaded the right code to your arduino. What does the IDE tell you when you hit "Upload"? It should say something like "upload complete".

Ok, know somehow it is working.I had few more issues with the serial monitor but I overcame them. Now stuck on step 3 because I am waiting for power supply, could I use my old 5V 1A PSU for 120light strip (2m) or the 5V 2A is essential??

I got some of these red and blue bluetooth modules too recently . On mine top left is a button. You are meant to hold down the button whilst you turn on the bluetooth module . That will drop it into the AT mode . I prefer these to all other modules I have had.

And also dont understand how I have to connect the LED strip to the arduino, according the diagram the LED goes to PSU and that to arduino but I am connecting directly to the PC so where should connect the LED wires ????

Just the arduino will run it successfully just for testing .Your 1 amp will do it while waiting , join all grounds and take arduino 5 volt to pos for a start

Not many people posting here now . I took down my post expressing concern at using bluetooth requires you to switch on data capabilities on android devices, after you showed me a page requiring it to be done . Reading here ->https://www.sciencedaily.com/releases/2017/04/1704...

I am still concerned with this . My phone is an android 5 system and my testing with MITAppInventor has indicated without doubt turning on media services is not required at all. I notice you have not yet released your .ala code file for the app . I would still like to see it as I have a problem with your app running on my phone . It will not switch the LEDS on although all that should be happening in the serial terminal is happening . I have had it running by changing one of the random seeds but I have lost that again and am still looking to get it to run . All other neopixle apps run as they should and so do any bluetooth apps I play with so I am sure it is your code . Further I suspect it is to do with trying to turn media services on which i do not allow on my phone when running apps.

0
user
Noro13

1 year ago

After I attached the FHT folder into the code and pressed upload an error pop up:

"

Arduino: 1.8.1 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Users\PC\Desktop\LED DR PROJECT\FWJ1RK3IXLATIL2\LED control code\LED_control\LED_control.ino:17:0:

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:180:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r16, "STRINGIFY(FHT_N/8)" \n" // prep loop counter

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:381:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r16, hi8((fht_input + "STRINGIFY(FHT_N*2)")) \n" // prep end of dataspace register

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:576:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"cpi r28, lo8(fht_input + "STRINGIFY(FHT_N*2)") \n" // check if at end of dataspace

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:590:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"sbrc r8, "STRINGIFY(LOG_N - 2)" \n" // check if finished with all butteflies

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:646:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r20, "STRINGIFY((FHT_N/2) - _R_V)" \n" // set to first sample

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:720:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r30, lo8(fht_input + "STRINGIFY(FHT_N*2)") \n" // set to end of data space

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:721:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r31, hi8(fht_input + "STRINGIFY(FHT_N*2)") \n"

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:724:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r20, "STRINGIFY(FHT_N/2)" \n" // set loop counter

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:877:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r30, lo8(fht_input + "STRINGIFY(FHT_N*2)") \n" // set to end of data space

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:878:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r31, hi8(fht_input + "STRINGIFY(FHT_N*2)") \n"

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:881:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r20, "STRINGIFY(FHT_N/2)" \n" // set loop counter

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:1058:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r30, lo8(fht_input + "STRINGIFY(FHT_N*2)") \n" // set to end of data space

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:1059:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r31, hi8(fht_input + "STRINGIFY(FHT_N*2)") \n"

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:1062:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r20, "STRINGIFY(FHT_N/2)" \n" // set loop counter

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:1216:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r20, "STRINGIFY(((FHT_N)&(0xff)))" \n"

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:1293:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r30, lo8(fht_input + "STRINGIFY(FHT_N*2)") \n" // set to end of data space

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:1294:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"ldi r31, hi8(fht_input + "STRINGIFY(FHT_N*2)") \n"

^

C:\Users\PC\Documents\Arduino\libraries\FHT/FHT.h:1446:3: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]

"sbrs r21, "STRINGIFY((LOG_N) - 1)" \n" // check if done

^

C:\Users\PC\Desktop\LED DR PROJECT\FWJ1RK3IXLATIL2\LED control code\LED_control\LED_control.ino: In function 'char* substring(const char*, int, int)':

C:\Users\PC\Desktop\LED DR PROJECT\FWJ1RK3IXLATIL2\LED control code\LED_control\LED_control.ino:576:15: warning: converting to non-pointer type 'char' from NULL [-Wconversion-null]

subarray[l] = NULL;

^

`_window_func' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`_window_func' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`fht_log_out' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`fht_log_out' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`_log_table' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`_log_table' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`_reorder_table' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`_reorder_table' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`_cas_constants' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

`_cas_constants' referenced in section `.text' of C:\Users\PC\AppData\Local\Temp\ccRUVXqa.ltrans1.ltrans.o: defined in discarded section `.text' of sketch\LED_control.ino.cpp.o (symbol from plugin)

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences."

and How do I connect the LED strip with the arduino????????

1 reply

Did you follow the steps I described in the tutorial to attach the FHT library? It seems like you've copied library files into the project, which is not the way it should be done.

As for the LED strip connection, all you need to make sure is that you provide 5V to the power input (directly from the power supply or from arduino's 5V pin), the ground you connect to the strip is also connected to arduino's GND pin (if you power it from arduino, just connect arduino's GND and strip's GND), and connect strip's digital input to the arduino's digital pin 8.