Music Reactive Mood Lights

by spikytuna in Circuits > Arduino

2833 Views, 39 Favorites, 0 Comments

Music Reactive Mood Lights

20200524_230815.jpg

Intro and Background.

Back in freshman year (Spring of 2019), I wanted to spruce up my dorm room. I came up with the idea of building my own mood lights which would react to the music I listened to on my headphones. Frankly, I had no particular inspiration, I just thought they looked cool. In the heat of finals season, I cobbled together an LED strip controller that could react to audio. It worked, but it was just a breadboard setup, far from anything complete or permanent. Time passed, homework piled up, and that project sank deeper and deeper into my box of unfinished things.

Then the quarantine struck.

I gained enough time to pursue the things I like and the energy to complete projects of days past. Thus, that lonely breadboard was rescued from the bottom of my pile and this project was finally (well, mostly) completed.

This is not a full fledged product, evident by the cardboard and shoddy programming, but a fun little decoration nonetheless.

(This Instructable is not as detailed, mostly due to how long ago this device was made.)

Prerequisites

Basic circuit knowledge and experience programming Arduino.

Note to Maker (You):

The mood lights that you will make will almost certainly not match what I have. Treat this Instructable more as a suggestion and put your own spin on it!

Supplies

  • Teensy++ 2.0 (or whatever Arduino you have)
  • Various resistors
  • Various switches
  • Various capacitors
  • 3.5 mm jack (male or female)
  • Potentiometers (or Encoders)
  • Audio Amplifier IC
  • Addressable LED strips
  • Headphone Splitter

These are Amazon affiliate links so I earn a little commission with each sale. If you don't already have these supplies and want to support future projects of mine, follow these links! :)

Plan Out and Breadboard

srl_di.png
vdivdi.png

The first step for any good project is to set up your requirements. This step is fairly open ended. It's up to you to make it as simple or complex as you want.

My Requirements

  • Control an addressable LED strip for mood lighting
  • Have an Audio reactive mode
  • Have a Static RGB mode - when I just want to see still lighting
  • Have a selector switch for swapping between modes
  • Have potentiometers for controlling RGB mode
  • Have a screw terminal to attach a 5V supply to

Once you've defined your requirements, the next thing to do is to determine what components you need and breadboard them out. Take my system diagram above as a guide! Testing is a critical step to work out bugs, to ensure the components work together, and to avoid time consuming mistakes.

Notes:

Why a voltage divider for the audio input?

You might have noticed that there is a voltage divider on the audio signal input line. This is to account for one of the limitations of the ADCs of Arduinos: The ADC can only read voltages between 0 - 5V. Since an audio signal is AC, it will have parts where it goes negative. We obviously don't want this negative voltage reaching the input pin, therefore we offset the signal with the voltage divider and keep it centered at 2.5V.

Why an amplifier?

I discovered that, when I used headphones or speakers with my breadboard setup, the signal was too weak to be processed by the Arduino. Adding an amplifier solved that issue. As you can see, testing beforehand is important!

Program

This code provided is what I used in my mood lights. You will definitely not use this code without tweaking it, due to differing hardware and board layouts. Take it more as an example to see how the libraries are utilized.

Libraries Used:

Fastled.h (For addressable LED control)

fix_fft.h (For an even faster fourier transform. This was necessary since other fourier transform libraries were too slow. The speed problem could possibly be circumvented with a faster microcontroller like an ESP32.)

Downloads

Perfboard It

20200301_080406.jpg

If you got the knowledge, I highly recommend designing a PCB instead of a perfboard. It's a far less tedious soldering process. I can't detail every solder joint I made, but here are a few key tips:

Tips:

Lay out your components on your perfboard to pre-fit them. This will save you a lot of headaches.

Put a bypass capacitor on your power rail to mitigate the effects of spikes in power draw.

Take advantage of the extra lead length offered by the through-hole capacitors and resistors. Use them to connect other points on your board.

Use female PWM connectors and male header pins for easy removal/attachment of components.

Use solid core wire when you can. It's easier to put into through-holes.

Build Enclosure

cardboard.jpg

It's time to build the enclosure for your new perfboard/PCB. I used cut cardboard because it was the best thing I had on hand. If you have a 3D printer or some other method, that's also good!

Tips:

Use calipers to measure out the dimensions of your board, especially if you're cadding a case.

If using cardboard

Always leave a little bit of leeway when cutting. You can always cut more, but you can never reattach.

Use a small knife or exacto knife. A small blade is key for making precise, well-fitting holes.

Enjoy

Music Reactive Mood Lights
RGB Control

Have fun with your new mood lights!

Things to expand on:

Making a proper case?

More patterns or modes?

A faster microcontroller?