This repository holds the Arduino program featured in the SparkFun tutorial on creating a music visualizer with a strip of addressable RGB LEDs.
The wish list for all these parts can be found here.
- SparkFun RedBoard (Any board with 3.3V and 5V pins will suffice.)
- LED RGB Strip - Addressable, Bare (1m)
- SparkFun Sound Detector
- Breadboard - Self-Adhesive (White)
- 3x Momentary Pushbutton Switch - 12mm Square
- Trimpot 10K with Knob (or any analog potentiometer.)
- Resistor 330 Ohm 1/6th Watt PTH (or any resistor between 300–500 Ω)
- Electrolytic Decoupling Capacitors - 1000uF/25V
- (if needed) Jumper Wires Standard 7" M/M Pack of 30
The resistor and capacitor are not required, but they will help prevent possible damage to the LEDs.
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. But 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 recommendable option.
- Electrolytic capacitors are polarity-sensitive, 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 aren't polar, but it's good practice to be consistent with their orientation relative to the current.
- Trimpots are not polar either, however their middle pin is the analog output so don't power that directly.
- Pushbuttons are not polarity-sensitive and also do not need to be powered directly, just a ground connection will suffice.
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 Detector | Addressable LED strip | Trimpot | Pushbutton | 1 mF (1000 µF) Capacitor | 300–500 Ω Resistor |
---|---|---|---|---|---|
Envelope → Analog (A0) | Digital/Analog (A5) → Resistor → DIN | 5V → left or right pin | GND → Either side | Between ground and 5V | Between Digital/Analog (A5) and DIN on LED strip |
3.3V → VCC | 5V → 5V | Middle pin → Analog (A1) | Other side → Digital (4, 5, 6) | ||
GND → GND | GND → GND | Remaining left or right pin → GND |
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 propagate, 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 check here.
**Diagram of a possible circuit:** ![diagram](http://i.imgur.com/Po12eSI.png)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;
tobool 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 theBUTTON
constants.