Introduction: Portable Party Lights

About: A maker and electronics enthusiast.

Can you bring light to a party and make it more fun?

That was the question. And the answer is YES (of course).

This instructable is about making a portable device that listens to music and creates music visualization out of concentric rings of Neopixel LEDs.

An attempt was made to make the device "dance", i.e., move to the beat of the music, but beat detection proved to be a more complicated task than it sounds (no pun intended), so "dancing" is a bit awkward, but still is there.

The device is Bluetooth-enabled and will respond to text commands. I did not have the time to write an App to control Party Lights (either Android or iOS). If you are up to the task - please let me know!!!

If you like this instructable, please vote for it in the Make It Glow contest!

Supplies

To build Party Lights you will need:

  • STM32F103RCBT6 Leaflabs Leaf Maple Mini USB ARM Cortex-M3 Module for Arduino (link here) - the brain of the device. These relatively cheap devices are so powerful, it is unclear why you would ever go back to an Arduino.
  • MSGEQ7 Band Graphic Equalizer IC DIP-8 MSGEQ7 (link here)
  • HC-05 or HC-06 Bluetooth module (link here)
  • Adafruit MAX9814 microphone (link here)
  • A standard servo motor (link here) is you want your device to "dance"
  • CJMCU 61 Bit WS2812 5050 RGB LED Driver Development Board (link here)
  • TTP223 Touch Key Module Capacitive Settable Self-Lock/No-Lock Switch Board (link here)
  • Ultra Compact 5000-mah Dual USB Outputs Super Slim Power Bank (link here)

  • Resistors, capacitors, wires, glue, screws, prototyping boards, etc. etc.

Step 1: The Idea

The idea is to have a portable device that could be placed close to a music source, and that would create colorful music visualizations. You should be able to control the device behavior via buttons (touch) and Bluetooth.

Currently, Party Lights have 7 visualizations implemented (let me know if you have more ideas!):

  1. Concentric colorful circles
  2. Maltese cross
  3. Pulsating lights
  4. Fireplace (my personal favorite)
  5. Running lights
  6. Light trees
  7. Sideways segments

By default, the device will cycle through the visualizations every minute. However, a user can choose to stick with one visualization and/or manually cycle through them.

Visualizations that rotate their color palette could also be "frozen" if a user likes a particular color combination.

And as a couple of more controls, the user can change the microphone sensitivity and enable/disable servo motor "dance" mode.

Step 2: Schematic and Sound Processing

A fritzing schematic file is included in the package on Github in the "files" subfolder.

Basically, an MSEQ7 chip does the audio processing, splitting an audio signal into 7 bands: 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, and 16kHz

The microcontroller uses those 7 bands to create various visualizations, basically mapping respective band amplitudes into LED light intensity and color combinations.

The sound source is a microphone with 3 levels of gain control. You can cycle through gain settings using one of the buttons depending on how far/loud the sound source is.

The microcontroller also attempts to perform "beat" detection on the 63Hz "bass" band. I am still working on a reliable way to detect and maintain beat alignment.

The use of "touch" buttons was an experiment. I think they work pretty well, however, lack of press feedback is confusing somewhat.

Step 3: LED Wheel

The core of visualization is a 61 LED wheel.

Please note that the part comes as individual rings which you will have to put together. I used rather think copper wires for power lines (which also hold the rings together nicely), and thin signal wires.

The LEDs are numbered 0 to 60 starting from the bottom outer LED and going clockwise inward. The center LED is number 60.

Each visualization relies on two-dimensional data arrays, which map each LED into a specific position for the target visualization segment.

For instance, for concentric circles, there are 5 segments:

  • Outer circle, LEDs 0 - 23, 24 LEDs long
  • Second outer circle, LEDs 24 - 39, 16 LEDs long
  • Third circle (center), LEDs 40 - 51, 12 LEDs long
  • Second inner circle, LEDs 52 - 59, 8 LEDs long
  • Inside LED, LED 60, 1 LED long

The visualization maps 5 out of 7 audio channels and lights up LEDs progressively according to their position in the circular band proportionate to the level of sound in the band.

Other visualizations use different data structures and formats, but the idea is always to have visualizations driven by the data arrays, not so much by the code. This way visualizations could be adjusted to different shapes (more or fewer LEDs, more EQ bands) without changing the code, just the values in the data arrays.

For instance, this is how the data structure for visualization 1 looks like in the sketch:

// Visualization 1 & 3 - full 5 circles<br>const byte TOTAL_LAYERS1 = 5;
const byte LAYERS1[TOTAL_LAYERS1][25] = {
  //00  01  02  03  04  05  06  07  08  09  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24
  { 24,   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 },
  { 16,  24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 },
  { 12,  40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 },
  { 8,   52, 53, 54, 55, 56, 57, 58, 59 },
  { 1,   60 }
};

Step 4: Visualizations

So far there are 7 visualizations and a start-up animation:

Start-up animation

When the device is turned on, an imitation of a firework is displayed. This was supposed to be a LED and Servo test sequence, but later evolved into an animated version of such test

Concentric colorful circles

The lights go around the display in concentric circles proportionate to the amplitude of the respective eq band. Randomly switching between clock- and counter-clock-wise and slowly rotating the colors over the 256 color wheel

Maltese cross

One band is the center LED. Another band is the vertical and horizontal lines of LEDs, and the remaining segments representing each an EQ band. All segments are rotating colors in 128 offset to remain contrast.

Pulsating lights

Each circle lights up all LEDs in unison for a dedicated eq band, while slowly rotating colors with a slight offset. EQ bands are progressively shifted from one circle to the next creating outward progression.

Fireplace

The bands are semi-circles lit up from the bottom to the top starting with a bright red and adding yellow on the way up simulating a burning fire in a fireplace. Occasional bright white "spark" randomly shoots up. There is no color rotation

Running lights

Each concentric circle is a separate EQ band. The leading LEDs are the ones on the vertical line below the center LED. Once the LED is lit proportionate to the band amplitude, it starts "running" around the respective circle slowly decreasing intensity. Both clock- and counter-clockwise rotations are supported, switching randomly.

Light trees

The segments are lit in a straight line from bottom LED up and then sideways in concentric semi-circles imitating palm trees. Color rotation.

Sideways segments

This is a version of the previous Maltese Cross with only 2 diagonal segments used. Supposed to resemble the icon for sound waves.

Step 5: Touch Button Controls

There are 4 touch-sensitive buttons:

  1. Cycle through visualizations and keep the current one going until another is chosen (by default visualizations cycle every 30 seconds)
  2. "Freeze" / "unfreeze" current color scheme - if you like a particular color combination you can freeze it - the color rotation is disabled and the visualization will continue with just this color palette
  3. Adjust microphone sensitivity
  4. Turn "dancing mode" on / off

In dancing mode, the device will try to detect the "beat" of the currently playing music and turn its head according to the beat. So far the "dancing" is rather awkward than beautiful, to be honest.

Step 6: Beat Detection and Servo "dancing"

The device is constantly trying to detect the "beat" of the current tune as a distance between consecutive peaks of the 63Hz band. Once detected (and only if the dance mode is ON), the device will activate its servo motor to randomly turn left or right according to the beat.

Any bright ideas on how to make this more reliable are welcome!

'Music_Test_LED' sketch outputs 7 EQ bands in a way suitable for plotting using Arduino IDE.

Step 7: 3D Shapes

The entire Party Lights assembly was designed from scratch using Autodesk TinkerCAD.

The original design is located here. The "files/3D" folder on github.com contains the STL models.

This design illustrates how the device looks assembled.

All of the components were printed and then assembled/glued together.

The "dome" is hosting the microcontroller, Bluetooth board, and a microphone. The microcontroller is placed on a 40mm x 60 mm board and is supported by designated rails.

The servo is located in the "leg" of the dome, while buttons are located in the base.

The battery compartment is printed specifically for the type of battery mentioned in the Supplies section. If you choose to use a different battery, the compartment will have to the re-designed accordingly.

Step 8: Power Supply

An Ultra-Compact 5000-mah Dual USB Outputs Super Slim Power Bank seems to be providing enough power for hours of operation.

The battery compartment is designed in such a way that it detaches from the rest of the device and could be replaced with the one designed for a different type of battery.

The USB plug was positioned and hot-glued in place to connect the battery as it slides in.

Step 9: Bluetooth Control

An HC-05 module is added to provide a way to control the device wirelessly.

When on, the device creates a Bluetooth connection called "LEDDANCE", which you can pair your phone with.

Ideally, there should be an App that allows controlling PartyLights (choosing a color palette, simulating button presses, etc.). However, I have not written one yet.

If you are interested in helping writing an Android or iOS App for Party Lights, please let me know!

To control the device, you can currently use the Bluetooth terminal app, and send the following commands:

  • LEDDBUTTn - where n is '1', '2', '3', or '4' simulates pressing a respective button. Ex.: LEDDBUTT1
  • LEDDCOLRc - where c is a number from 0 to 255 - position of the desired color on a color wheel. The device will switch to the specified LED color.
  • LEDDSTAT - returns a 3 character number consisting of '0's and '1's only:
    • first position: '0' - colors are not rotating, '1' - colors are rotating
    • second position: '0' - dancing mode is off, '1' - dancing mode is on

    • third position: '0' - microphone is in normal gain, '1' - microphone is in high gain

Step 10: Control App Based on Blynk

Blynk (blynk.io) is a hardware-agnostic IoT platform. I used Blynk in my IoT Automatic Plant Irrigation System instructable and was impressed with the ease and robustness of the platform.

Blynk supports connecting to edge devices via Bluetooth - exactly what we need for PartyLights.

If you have not already, please download Blynk App, register and recreate Blynk PartyLights App using the screenshots attached to this step. Please make sure the virtual pin assignments are the same as on the screenshots, otherwise, the buttons on the app will not work as intended.

The file "blynk_settings.h" contains my personal Blynk UID. When you create your project, it will be assigned a new one fo you to use.

Upload the PartyLightsBlynk.ino sketch, fire up the App. Pair with Bluetooth device and enjoy the party.

Step 11: Sketches and Libraries

The main sketch and supporting files are located on Github.com here.

The following libraries were used in the Party Lights sketch:

  • TaskScheduler - cooperative multitasking - here (developed by me)
  • AverageFilter - templated average filter - here (developed by me)
  • Servo - Servo control - is a standard Arduino library
  • WS2812B -NEOPixel control - comes as part of STM32 package

This Wiki page explains how to use STM32 boards with Arduino IDE.

Step 12: Future Improvements

A few things could be improved in this design, which you might consider if you embark on this project:

  • Use ESP32 instead of Maple Mini board. ESP32 has 2 CPUs, Bluetooth and WiFi stacks, and can run at 60MHz, 120MHz and even 240MHz.
  • Smaller design - the resulting device is big-ish. Could be more compact (especially if you drop the dancing idea and associated servo)
  • Beat detection could be infinitely improved. What comes naturally to us humans, seems to be a difficult task for a computer
  • A lot more visualizations could be devised and implemented.
  • And, of course, an App could be written to control the device wirelessly with a cool UI.
Make it Glow Contest

Participated in the
Make it Glow Contest