Skip to main content Tiny Arduino Music Visualizer Code
Overview
Wiring
Code
Ideas
Single page
Feedback? Corrections?
Text View
Featured Products view all
Your browser does not support the video tag. Adafruit Bicolor LED Square Pixel Matrix with I2C Backpack $15.95 Add to Cart
Electret Microphone Amplifier - MAX4466 with Adjustable Gain $6.95 Add to Cart
Adafruit METRO 328 Fully Assembled - Arduino IDE compatible Out of Stock
Breadboarding wire bundle $4.95 Add to Cart
Half Sized Premium Breadboard - 400 Tie Points $4.95 Add to Cart
183 Beginner Project guide
Code
This button will download a folder containing all the code needed for this project:
Download “Piccolo” Arduino source code
The code can also be found on Github.
After uncompressing the ZIP file, inside you’ll find a folder called Piccolo. This can be moved to your Arduino documents folder if you like. The Piccolo.ino file in there is the main project source code — open this in the Arduino IDE.
Two libraries are required for this: Adafruit_LEDBackpack and Adafruit_GFX. If you worked through the basic LED matrix backpack guide first, these should already be present. Otherwise, both can be found in the Arduino Library Manager (Sketch→Include Library→Manage Libraries…)
With the Piccolo sketch open, select your Arduino board type and serial port from the Tools menu. Then click the Upload button. After a moment, if all goes well, you’ll see the message “Done uploading.” The project should now be responsive to sound…try clapping your hands!
Troubleshooting
If there’s no response from the device, try the following:
Test the matrix using the example code from the Adafruit_LEDBackpack Library. If there’s no response, the clock and data pins might be swapped, or the matrix may have been soldered to the board backwards.
Double-check all wiring against the diagrams. Did you include the 3.3V-to-AREF connection? D and C pins from the matrix backpack should connect to SDA and SCL on newer Arduinos, or analog pins 4 and 5 on older boards.
The gain on the mic amplifier may be set low. There’s a dial on the back of the board that can be adjusted with a small screwdriver.
Try increasing the music volume.
Principle of Operation
Using the normal Arduino analogRead() function would be much too slow for sampling audio. Instead, a feature of the microcontroller’s analog-to-digital converter called free-run mode is utilized. This automatically takes repeated analog samples at precise intervals…about 9.6 KHz for this project, the maximum a 16 MHz Arduino can handle with 10-bit samples.
This is strictly mono. There isn’t enough RAM or processor oomph for stereo.The raw audio samples are converted into a frequency spectrum using a fast Fourier transform or FFT. There are a number of Arduino FFT libraries out there, but we keep finding ourselves returning to the venerable ELM-ChaN ffft library for its speed and good looks.The FFT output still needs a bit of massaging to make for a good presentation on the limited 8x8 matrix. Several tables of scales and weights de-emphasize certain frequency ranges as they’re reduced to just eight columns. The software works at keeping the graph interesting, but some columns will always be less lively than others, especially comparing live speech against music of varying genres. If everything seems to stick toward one end of the graph, try another musician, musical genre, or different speakers.
Page last edited January 22, 2025
Text editor powered by tinymce.
Wiring Ideas Related Guides Adafruit LED Backpacks By M. LeBlanc-Williams intermediate Adafruit Ultimate GPS By lady ada beginner Your browser does not support the video tag. This links to the guide 3D Printed LED Microphone Flag. 3D Printed LED Microphone Flag By Ruiz Brothers beginner OLED TRON Clock By Dan Malec intermediate Your browser does not support the video tag. This links to the guide Ursula's Seashell Necklace. Ursula's Seashell Necklace By Erin St Blaine intermediate Arduino Lesson 0. Getting Started By Simon Monk beginner Adafruit 4-Channel ADC Breakouts By Liz Clark beginner Circuit Playground Sound-Controlled Robot By Anne Barela beginner Arduino Lesson 14. Servo Motors By Simon Monk beginner Adafruit Microphone Amplifier Breakout By Bill Earl intermediate Adafruit Motor Shield By lady ada intermediate NeoPixel Painter By Phillip Burgess beginner TMP36 Temperature Sensor By lady ada beginner FTDI Friend By lady ada beginner Low Power Coin Cell Voltage Logger By Phillip Burgess beginner Your browser does not support the video tag. This links to the guide Gemma-Powered NeoPixel LED Sound Reactive Drums. Gemma-Powered NeoPixel LED Sound Reactive Drums By Ruiz Brothers intermediate