Introduction: Musically Synchronized Christmas Lights / Spectrum Analyzer - Via Arduino Nano and MSGEQ7
Last year, I was on the hunt to find a way to automate my Christmas lights to respond to music. I found a lot of tutorials but mostly ones that involved programming the light sequence into a lighting program like Vixen. There's nothing wrong with Vixen, but I just didn't want to sit there programming a few songs; instead, I wanted something that would respond to the music so I wouldn't have to code each song I wanted to play. That's when I found a couple of projects by Justbarran.
Justbarran's (2) Christmas Lighting tutorials are what really enticed me to build my own iteration of his world famous Automatic Musical Christmas Lights. I followed his tutorial and it worked very well, I got a lot of positive feedback on it and I liked that you could play any song you wanted. But I wasn't completely satisfied yet, because there were some minor drawbacks.
Problems:
- I ended up using Mechanical Relays, but these were slow and eventually failed over time.
- The audio speaker I used (Sony SRS XB22 EXTRA BASS Portable Wireless Speaker) went quiet when the temperature dropped below -5°C and could barely be heard at the road.
- People driving by couldn't hear the music, at all.
- The MSGEQ7 IC controlled seven individual light runs, but there was only one potentiometer to control the level at which all (7) light runs were triggered. One potentiometer setting worked fine for some songs, but for other songs, it either resulted in runs of lights being on all the time or not at all for the entirety of the song.
Solutions:
- Provide (7) potentiometers to individually control the level at which each light run is triggered.
- Swap the mechanical relays for Solid State Relays
Upgrades:
- Swap the Arduino Pro Mini for an Arduino Nano to provide more Analog pins for the required potentiometers.
- Upgrade the code to accommodate (7) potentiometers.
- Add a third audio jack for an FM Transmitter.
- Include an FM Transmitter to extend music to passing cars.
- Upgrade the audio system so the music plays loud in all temperatures.
Budgeting Notes:
- Over the course of (2) years, this is project has cost me between $800-$1000 Canadian, as listed, but is totally worth it in my opinion.
- If you're looking to cut costs, you could omit the FM Transmitter, which will save you close to $200.
- Also, feel free to substitute components, like the audio stereo or anker Bluetooth receiver for something that you might already have. Or perhaps you already have Christmas lights, etc...
Supplies
Low Voltage Side - Circuit Components:
- (1) - Audio Frequency Analyzer Chip - MSGEQ7 - There are a lot of counterfeit chips out there - I bought a few chips off of amazon that gave me problems, after troubleshooting, I discovered that these counterfeit chips are essentially defects. So save yourself any headaches and buy from a reputable electronics or robotics store.
- (3) - 3.5mm Audio Jack Adapter (PJ-307)
- (1) - Arduino Nano Every Microcontroller with Headers
- (1) - Assorted Resistor Kit – 600 Pieces
- (1) - Ceramic Capacitor Kit – 250 Pieces
- (7) - 10K Ohm Breadboard Friendly Potentiometer
- (1) - 8x8 LED Matrix Display Max7219 LED Matrix Panel
- (1) - Solid State Relay Module, 8 Channel
- (1) - 3x40 Break Away Header
- (1) - Anker Soundsync A3352 Bluetooth Receiver
- (1) - Solderless BreadBoard - White
- (1) - 22 AWG Solid Core Wire Kit - misc colours
- (1) - 90 piece PCB Terminal Block 2P 3P 4P 5mm Pitch, 300V 15A Screw Terminal Block for PCB
- (1) - 10pcs 7x9cm Universal PCB Prototype Single Sided DIY Universal Circuit Board
- (1) - Sticky PCB Spacer Adhesive Standoffs
- (1) - 5V DC adapter with USB-C connector (Cell phone charger)
High Voltage Side - Circuit Components:
- (2) - Two gang device box 3 in. x 3-3/4 in. x 2-1/2 in. deep
- (1) - 14/2 NMD90 5M Romex SIMpull Electrical Wire - White
- (1) - CAN-TWIST 100 Pak One Size Fits All!
- (1) - Decora Tamper Resistant Electrical Outlet Receptacle in White (10-Pack)
- (1) - Decora wall plate 2 Gang, White
- (1) - 9 ft. 14 Gauge 15 Amps Indoor & Outdoor Medium Duty Extension Cord for Appliance, Black
Sound Components:
- (1) - Whole House FM Transmitter 3.0
- (1) - Nobsound Mini 50W x 2 Bluetooth Power Amplifier; 2.0 Channel Stereo Hi-Fi Digital Amp
- (1) - Herdio 5.25 Inches 200 Watts Indoor Outdoor Speakers All Weather Wall Mount System Pair
- (1) - Pure Copper Speaker Wire with Gold Plated Banana Plugs, 14AWG, 6 Feet (2 Meter), Pair
Enclosure:
- Sheet of 1/4" Plywood or OSB
- Framing material (2x4 lumber or what ever you might have available)
- Door hinges
- Door Latch
- Acrylic panel for the door, if you want to be able to see inside the enclosure like I did
- Wood Screws
- Weather Stripping Sealer around all gaps and holes
- Paint
Tools:
- Wire Cutters
- Wire Crimpers
- Soldering iron
- Solder
- Desoldering tool
- Glue gun
- Wood Working tools for the Wood Enclosure (Table saw or hand saw, Jig Saw, drill, file, sandpaper)
Misc:
- Atleast, (7) runs of Christmas lights
- Christmas Light Connectors
- Surge Protector
- Dedicated Cell Phone, Tablet or PC with a music streaming app.
Step 1: Circuit Diagram
The main component of this project is the MSGEQ7 Integrated Circuit. It's a seven-band graphic equalizer chip that divides the input audio spectrum into seven bands, 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and 16kHz. The seven frequencies are peak detected and multiplexed to provide a DC representation of the amplitude of each band. No external components are needed to select the filter responses. Only off-chip resistors and capacitors are needed to select the on-chip clock oscillator frequency. You can find the data sheet available for download, below.
The major difference between this design and Justbarran's is that I added (7) individual potentiometers to set the trigger value for each of the seven bands. This means more on the fly control and fine tuning adjustment. As result of using (7) analog devices (potentiometers) meant that I needed to swap the Arduino Pro Mini for an Arduino Nano which provides enough analog pins to support this change. Otherwise, the circuit is very similar to Justbarran's design.
Attachments
Step 2: Edit, Compile and Upload Code
If this is your first time experimenting with Arduino, then I encourage you to get acquainted by doing some tutorials first. I bought and read the book Arduino Workshop: A Hands-On Introduction with 65 Projects and it was simple and easy reference.
Arduino is a pocket-sized computer (also commonly referred to as a "microcontroller") that you can program and use to control circuits. In order to make the Arduino function, you'll have to program the microcontroller thru the Arduino Integrated Development Environment (IDE). Again, this is beyond the scope of this project, so if you're unsure how to use the Arduino IDE, do a few tutorials until you feel comfortable with it.
The Code has been provided in the download link below. Much of this code was derived by Justbarran, but I made a few modifications as required by the upgrades implemented.
The code also has a dependency for a library called "LedControl.h" to control the 8x8 matrix display. Be sure to add this library before compiling the code, otherwise, you will encounter some errors.
It appears that some Solid State Relays come Normally Open or Normally Closed, so depending on which version of Solid State Relay you have, you might have to change the following code from this:
#define LED_LOW HIGH //was LOW
#define LED_HIGH LOW //was HIGH
to this:
#define LED_LOW LOW
#define LED_HIGH High
The code is written to assume you'll be using Solid State Relays, which is what I recommend too, but if you decide to use mechanical relays, you'll want to adjust the code to slow down the response time, otherwise, you will prematurely burn out the mechanical relays. You can slow down the response time by editing this line:
#define CYCLE_DELAY 50 // set to 100 for mechanical relay, set to 50 for solid state relay
to this:
#define CYCLE_DELAY 100
Otherwise, that should be all you need to adjust. Compile and upload the code to the Arduino Nano and you're done with the code!
Step 3: Assemble Low Voltage Breadboard Circuit
I always start my projects on a breadboard and then later transfer it over to a solderable prototype board. That's just my work flow because I'm relatively new to circuit design and its easier to fix a mistake on a breadboard than it is on a prototype board.
If you're new to building circuit boards and never used a breadboard, I recommend that you familiarize yourself with the image above of the breadboard with green lines. The green lines illustrate the connection of certain sockets in one direction as a bus or terminal, but notice that not all sockets are connected together. This is imperative to know when building breadboard circuits.
Using the circuit diagram from Step 1 as reference, I gather all my components and lay them out as methodically as I can on the breadboard. Again, this is just for proof of concept, so it doesn't need to be perfect, so don't stress over it. Then I begin connecting the components with pieces of wire to develop the circuits.
Once you've completed your circuit, double and triple check all your connections to make sure you're not shorting anything out. If everything looks good, proceed to plug in your power supply and watch for any smoke or sparks. I'll even proceed to feel the wires for excessive heat. Smoke, Sparks or Hot wires usually indicate a short in the system and the circuit should be immediately powered off and re-inspected. If everything is good, then proceed to test the audio.
Plug in the Bluetooth receiver into one of the audio jacks, and plug in a speaker into one of the other Audio Jacks. Get you phone, tablet or PC connected to the Bluetooth receiver. Load up some music, I use Spotify, but you can use YouTube or any other streaming service. Verify that you can hear music coming out of the stereo. If you don't hear any music, make sure the speaker isn't muted and that your audio jacks are secure to the breadboard, a little wiggle is all it takes sometimes. If you can hear music, proceed to check the 8x8 matrix.
With the music playing, the 8x8 matrix display should be dancing up and down according the highs and lows to the music. If your 8x8 Matrix isn't responding to music, then you may not be connected properly. Review all your connections and make sure there are no errors or bad connections. If your 8x8 Matrix is responding to the music, great, now you can test the Potentiometers and the Relays.
The (7) potentiometers drive the level at which the music triggers the relays. With the music playing, experiment with the potentiometers and see how they affect the response of the relay. If the potentiometers don't do anything, double check the connections, again, a little wiggle is all it takes sometimes; however, potentiometers can be bad, so if you have one misbehaving, try swapping it out for one that you know works.
Step 4: Assemble Low Voltage Prototype Circuit Board
When you've finished testing the breadboard circuit and you're satisfied that everything is working as it should, you can proceed to transfer components over to a prototype board and solder it up.
Once you've completed your prototype board, double and triple check all your connections to make sure you're not shorting anything out. If everything looks good, proceed to plug in your power supply and watch for any smoke or sparks. I'll even proceed to feel the wires for excessive heat. Smoke, Sparks or Hot wires usually indicate a short in the system and the circuit should be immediately powered off and re-inspected. If everything is good, then you can proceed to assemble the High Voltage Circuit.
Step 5: Assemble High Voltage Circuit
This portion can be dangerous and should be completed or atleast inspected by licensed electrician. I make no claims that my arrangement is safe and should not be trusted nor used as reference.
Essentially, the high voltage circuit is anything that carries 120V. This includes the connection from the power supply to the outlets and to the relays.
Before wiring up the receptacles, you'll need to remove the tab link from each of the (4) receptacles (see images for removal instructions). Removing this tab allows the top and bottom receptacle to become individual circuits.
With the tab links removed, you can now wire up your receptacles. Using a 15 Amp rated Outdoor Extension Cord, cut the female end completely off. Strip the wires and begin connecting the Wires to the stripped end of the extension cord.
The Ground wire (Bare copper or green wire) can connect to the gang box and/or to the receptacles. The Live Wires (Black wire) will connect to each of the (7) terminals on the relay. One black wire will connect to the last receptacle, making this last receptacle always live, and is what I plug my Surge Protector into to power the internal components (ie. Low Voltage Prototype Circuit Board, FM Transmitter, Mini Amp). Now connect the neutral wire (white wire) to each receptacle. Lastly, cut (7) lengths of Romex wire and collect the black wires. Connect each of the (7) black wires to the relay and the other end to each receptacle where you previously removed the tab link.
Step 6: Assemble Into Weather Resistant Enclosure
Since I live in Canada, we're subjected to winds, rain, sleet and snow during the month of December, so I opted to enclose all my electronics in a custom made wooden box.
I built mine out of 1/4" Oriented Strand Board (OSB), a piece of 2x4 for mounting the Gang Box to, and some 1x2.
The roof has a shallow pitch to shed the snow and water off. And I put a door on the front to access or service the components. The door also has a piece of 1/16" thick acrylic panel so I can easily see inside, and is where I decided to mount the 8x8 matrix display as well as the (7) potentiometers.
In retrospect, I wish I didn't make the enclosure so big and would've preferred hanging it on the wall at around eye level to prevent me from having to kneel every time I peer inside.
Step 7: Set Up Speakers and FM Transmitter
I bought my speakers used, but make sure that you get exterior rated speakers. The speakers were also originally white and made my house look like Goofy's smile, so my wife had me spray paint them brown to match my exterior trim and add a piece of 2x8 lumber to conceal the gap between the speakers which I also painted brown.
Otherwise, the install is simple, just hang the speakers and plug them into the mini amp. Voila, done!
Step 8: Lighting Arrangement
One note of caution, all (7) of the light runs are likely being fed by a single 15 amp service. At 120V supply, that equates to 1800W maximum power supply.
I use incandescent light bulbs on my setup (Heritage Ceramic Incandescent String Lights - 20-Count - Multicolor), which draw approximately 100w per strand and I think I use 13 strands total, so that equates to 1300W. Plus I run (3) LED flood lamps out front each consuming 50W each, so my total power consumption when all lights are on is 1450W. So I'm pretty limited and can't add any more lights to my setup. However, LED lights are far more efficient and draw much less power. So, if you have to run a lot of lights, consider using LED's.
For this step I sat down and drew an elevation plan of the front of my house and separated (7) areas each assigned to a light run. In my case, my house is a two story building and is appointed high on the property, so I opted to use (3) Flood Lamps split into a single run. The Red Flood Lamp pointed at the house, The Green Flood Lamp pointed to a big tree in the front yard and the White Flood Lamp pointed at the house. The other (6) runs were strung across the garage door, the front door, the main floor window, the second floor window, the garage roof line and the second floor roof line. This essentially covered my entire house.
Now, your house/property will likely be different, so setting up the lights is really user specific. Perhaps you have a bungalow and you're only able to use (4) runs on the house before its fully lit, then I'd consider using the remaining (3) runs to light up any available trees or Christmas Yard Ornaments.
I use Christmas light clips to connect the lights to my roof and use hot glue to adhere the bulbs to brick and metal flashing. I was hesitant to use hot glue in the beginning, but after using it one season, I was surprised how well it worked and released from the building.
Step 9: Show Time!
I plug in my music controller into a Geeni Indoor/Outdoor Weatherproof Smart Plug and schedule a start and end time for the controller to power up each day, usually between 4:00pm and 11:00pm, 7 days a week works well during the winter. I leave the Bluetooth Receiver and FM transmitter in the ON position, so when the Smart plug powers up, everything is ready.
This next step is a manual operation, that I hope to automate in the future. Gather your Phone, tablet or PC and load up a Christmas playlist from a streaming service and make sure your Bluetooth connects to your Bluetooth receiver.
If everything is working as it should, you should be able to hear the Music and see the Christmas Lights dancing to the beats.
I set my FM transmitter to 88.9 FM because that is what's open in my area, and I have a sign on the yard that says "Tune into 88.9 FM". Get in your car and test your FM station - hopefully it works too.
![First Time Author](https://content.instructables.com/FK9/YRHS/LLWBKNEI/FK9YRHSLLWBKNEI.jpg?auto=webp&crop=1240%2C600&frame=1&width=320)
This is an entry in the
First Time Author
Comments