Quantcast
Channel: SparkFun Tutorials
Viewing all articles
Browse latest Browse all 1123

Addressable RGB LED Music and Sound Visualizer

$
0
0

Addressable RGB LED Music and Sound Visualizer a learn.sparkfun.com tutorial

Available online at: http://sfe.io/t470

Introduction

Let’s face it: nowadays, most musical performances are complimented by some fancy light shows. Go to any concert, festival, club – they all have a corresponding visual performance or effects. Why not add your own home to that list? Here’s a simple yet effective project to make your very own son et lumière!

All palettes work with every visualization, but, for timeliness, not every combination is shown.

Required Materials

To follow along with this tutorial, you’ll need the following:

Any microcontroller with 3.3V and 5V pins will suffice, any analog potentiometer should work, and any resistor between 300–500 Ω can be used. The resistor and capacitor are not required, but they will help prevent possible damage to the LEDs.

If you’re compiling from the Arduino IDE or similar, you’ll want to snag the the NeoPixel Library since the code used is heavily based on it. If you’re using codebender, it will link the library for you.

Depending on your intent, the trimpot and buttons may not be necessary. The trimpot is only used to adjust the brightness threshold, so, if you want maximum brightness, you don’t have to worry about incorporating it. The three buttons cycle visualizations, color schemes, and shuffle mode respectively, so, if you want to do without those features (and just use shuffle mode all the time), that’s also a possibility.

It is also suggested that you use an Arduino and Breadboard Holder to simplify wiring and to mount the LED strip:

Full Visualizer

A small notch was cut in the BReadboard Holder to hold a piece of MDF, on which the LEDs are attached.

Recommended Reading

Before embarking upon this tutorial, you may find the following links useful:

Since we’re using the NeoPixel library, it may also be a good idea to get familiar with the NeoPixel Documentation.

Assembly

This project requires virtually no soldering! The few exceptions will probably be soldering some pins to the sound detector, and, if you’ve cut a roll of addressable LEDs in the middle, you’ll have to solder some wires to the starting LED’s pins. If you’ve never soldered before, I highly suggest taking a look at this guide.

Below is also a general chart for how the pin(s) on each component should be routed and an accompanying diagram. Before you begin, here are some things to keep in mind:

  • Be conscious of the orientation you think would allow the sound detector to take optimal readings for your intentions. Bending the pins to hold the sound detector perpendicular to the breadboard is a recommended option.
  • Electrolytic capacitors are polarized, so how they are oriented is important. Make sure to place the side with a white stripe and a negative symbol into a negative current (ground) and the other into positive current.
  • Resistors and pushbuttons are not polarized.
  • Trimpots are not polarized either, however their middle pin is the analog output, so don’t power that directly.

The pins used in the diagram and the code are in parentheses. If you use a different pin, don’t forget to change it in the code as well:

Sound DetectorAddressable LED stripTrimpotPushbutton1 mF (1000 µF) Capacitor300–500 Ω Resistor
Envelope → Analog (A0)Digital/Analog (A5) → Resistor → DIN5V → left or right pinGND → Either sideBetween ground and 5VBetween Digital/Analog (A5) and DIN on LED strip
3.3V → VCC5V →5V>Middle pin → Analog (A1)Other side → Digital (4, 5, 6)
GND → GND
GND → GND
Remaining left or right pin → GND

alt text

Sound Detector Notes: The microphone used is not a sophisticated, logarithmic sound receiver like your ear; it is only measuring compressional waves in the air. Consequently, the microphone is more likely to detect and/or prioritize lower-frequency sounds since they require more energy to propagat, and therefore oscillate the air more intensely. Also, a resistor can be placed in the “GAIN” slots to modify the gain. Standard gain should be sufficient for our purposes, but, for more info, visit this tutorial.

The entire circuit should look something like the diagram below.

alt text

Fritzing diagram for the circuit as described above. Click the image for a closer look.

Programming

Below is a small sample program to test if everything is connected properly. It only contains one visualizer and one color palette to keep things concise. It doesn’t need buttons since there’s nothing to toggle, but you can still use it to test your potentiometer.

The complete program featured in the video can be found at this GitHub repository.

Things to remember before you compile:

  • If you didn’t use a potentiometer, don’t forget to remove all references to the variable knob in the code (ctrl+F will come in handy for that). Otherwise, the program will think you still have a potentiometer that is set to a very low value (i.e. everything will be very dim).
  • If you didn’t use buttons, change the initialization bool shuffle = false; to bool shuffle = true;. The code should compile and run properly, but for good practice you should remove all blocks the code says to delete since they reference the BUTTON constants.
NOTE: For this example, we're hosting the code on codebender, which not only features code-sharing, but also allows anyone to upload and debug Arduino sketches from within a web browser. Plus, it works on lower-tech machines, like Chromebooks!

There are codebender plugins for Chrome, Chromium, and Firefox. Visit the codebender plugin page for help installing the codebender plugin.

Final Touches

With the electronics and the code working, you can now add your visualizer to a variety of enclosures or art pieces. For the final touches on this project, an elk was laser etched on a piece of acrylic. The LED strip was then wrapped around the outer perimeter of the piece.

Elk

Add some music, and you have yourself a beautiful piece of interactive art.

Resources and Going Further

To see all the code used int his project, visit the GitHub repository.

Need more inspiration? Check out these other SparkFun tutorials:

MiniGen Hookup Guide

Using the MiniGen, SparkFun's Arduino Pro Mini signal generator shield

Interactive Hanging LED Array

Learn how we converted 72 lightbulbs into an interactive LED array for our conference room.

Hackers in Residence - The ElectricBone

Drum machines and keyboards have been the standard for making digital music, but how do you make electronic music if you're trained to play the trombone? One of our Hackers in Residence, Carlos Mello, took it upon himself to find a solution to that very question.

Sound Reactive EL Wire Costume

Learn how to make your EL wire costumes sound reactive in this project tutorial.

learn.sparkfun.com |CC BY-SA 3.0 | SparkFun Electronics | Niwot, Colorado


Viewing all articles
Browse latest Browse all 1123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>