Neopixel Mini Vu Meter
Neopixel Mini Vu Meter
https://learn.adafruit.com/neopixel-mini-vu-meter
Overview 5
• Parts
Circuit Diagram 8
• Adafruit Library for Fritzing
• Wiring Connections
CircuitPython 9
• CircuitPython Quickstart
• Safe Mode
• Flash Resetting UF2
CAD files 18
• CAD Parts List
• Build Volume
• Acrylic Template
• SVG File for Laser cutter or CNC Mill
• CAD Assembly
• Design Source Files
Wiring 20
• 4-pin Cable
• Wire Mic Cable to QT Py
• Connect Mic Wires to QT Py
• Connect & Check Wiring
• Cut NeoPixel Strip
• Wire for NeoPixel Strip
• Solder Cable to NeoPixel Strip
• Wired NeoPixel Strip
• Connect NeoPixel to QT Py
• Final Wire Check
Assembly 24
• Hardware for PDM Mic
• Secure PDM mic
• Connect PDM Mic Cable
• Installing QT Py
• Install QT Py
• Install LED Acrylic to Case
• Install Grid into Case
• Prep NeoPixel Strip
• Install NeoPixel Strip
• Install Strip Cover to Case
Build a mini VU meter inspired project using NeoPixels and CircuitPython! Powered by
the QT Py RP2040, use a PDM microphone to turn audio data into a dazzling display
with NeoPixels!
QT Py RP2040 (http://adafru.it/4900)
PDM Mic (http://adafru.it/4346)
Mini Skinny NeoPixel Strip 144/
meter (http://adafru.it/2969)
Black LED Acrylic - Sheet (http://adafru.it/
4594)
10-wire ribbon cable (http://adafru.it/3890)
Stemma QT Cable (http://adafru.it/4209)
M2.5 Hardware Kit (http://adafru.it/3299)
Adafruit QT Py RP2040
What a cutie pie! Or is it... a QT Py? This
diminutive dev board comes with one of
our new favorite chip, the RP2040. It's
been made famous in the new
https://www.adafruit.com/product/4900
Use Adafruit's Fritzing parts library to create circuit diagrams for your projects.
Download the library or just grab individual parts. Get the library and parts from
GitHub - Adafruit Fritzing Parts (https://adafru.it/AYZ).
Wiring Connections
NeoPixels
PDM Mic
CircuitPython
CircuitPython (https://adafru.it/tB7) is a derivative of MicroPython (https://adafru.it/BeZ)
designed to simplify experimentation and education on low-cost microcontrollers. It
makes it easier than ever to get prototyping by requiring no upfront desktop software
downloads. Simply copy and edit files on the CIRCUITPY drive to iterate.
CircuitPython Quickstart
Follow this step-by-step to quickly get CircuitPython running on your board.
If the drive does not appear, release all the buttons, and then repeat the process
above.
You can also start with your board unplugged from USB, press and hold the BOOTSEL
button (highlighted in red above), continue to hold it while plugging it into USB, and
wait for the drive to appear before releasing the button.
A lot of people end up using charge-only USB cables and it is very frustrating! Make
sure you have a USB cable you know is good for data sync.
Safe Mode
You want to edit your code.py or modify the files on your CIRCUITPY drive, but find
that you can't. Perhaps your board has gotten into a state where CIRCUITPY is read-
only. You may have turned off the CIRCUITPY drive altogether. Whatever the reason,
safe mode can help.
Therefore, whatever you may have done to put your board in a non-interactive state,
safe mode gives you the opportunity to correct it without losing all of the data on the
CIRCUITPY drive.
To enter safe mode when using CircuitPython, plug in your board or hit reset
(highlighted in red above). Immediately after the board starts up or resets, it waits
1000ms. On some boards, the onboard status LED (highlighted in green above) will
blink yellow during that time. If you press reset during that 1000ms, the board will
start up in safe mode. It can be difficult to react to the yellow LED, so you may want to
think of it simply as a slow double click of the reset button. (Remember, a fast double
click of reset enters the bootloader.)
In Safe Mode
If you successfully enter safe mode on CircuitPython, the LED will intermittently blink
yellow three times.
If you connect to the serial console, you'll find the following message.
Auto-reload is off.
Running in safe mode! Not running saved code.
CircuitPython is in safe mode because you pressed the reset button during boot.
Press again to exit safe mode.
You can now edit the contents of the CIRCUITPY drive. Remember, your code will not
run until you press the reset button, or unplug and plug in your board, to get out of
safe mode.
Once you've finished setting up your QT Py RP2040 with CircuitPython, you can
access the code and necessary libraries by downloading the Project Bundle.
To do this, click on the Download Project Bundle button in the window below. It will
download as a zipped folder.
import time
import array
import math
import board
import audiobusio
import simpleio
import neopixel
# neopixel setup
pixel_pin = board.A0
pixel_num = 16
# mic setup
mic = audiobusio.PDMIn(board.TX,
board.A1, sample_rate=16000, bit_depth=16)
samples = array.array('H', [0] * 160)
# neopixel colors
GREEN = (0, 127, 0)
RED = (127, 0, 0)
YELLOW = (127, 127, 0)
OFF = (0, 0, 0)
while True:
# take in audio
mic.record(samples, len(samples))
# magnitude holds the value of the mic level
magnitude = normalized_rms(samples)
# uncomment to see the levels in the REPL
# print((magnitude,))
# if the mic input has changed from the last input value...
if last_input != input_val:
for i in range(input_val):
# if the level is lower...
if last_input > input_val:
for z in range(last_input):
# turn those pixels off
pixels[z] = (OFF)
# turn on pixels using the colors array
pixels[i] = (colors[i])
pixels.show()
# update last_input
last_input = input_val
time.sleep(0.01)
• lib folder
• code.py
Your QT Py RP2040 CIRCUITPY drive should look like this after copying the lib folder
and the code.py file.
# neopixel setup
pixel_pin = board.A0
pixel_num = 16
# mic setup
mic = audiobusio.PDMIn(board.TX,
board.A1, sample_rate=16000, bit_depth=16)
samples = array.array('H', [0] * 160)
# neopixel colors
GREEN = (0, 127, 0)
RED = (127, 0, 0)
YELLOW = (127, 127, 0)
OFF = (0, 0, 0)
The Loop
In the loop, data is received by the PDM mic and is held in the variable magnitude .
magnitude is scaled to fit into the range of 0 to 16 using map_range() . This
allows the 16 NeoPixels to represent the range of data coming from the PDM mic.
# take in audio
mic.record(samples, len(samples))
# magnitude holds the value of the mic level
magnitude = normalized_rms(samples)
# uncomment to see the levels in the REPL
# print((magnitude,))
A for statement is used to iterate through the range of the current input data from
the PDM mic. The index, represented with i , is used to turn on the correct number of
pixels and the defined colors from the colors array.
# if the mic input has changed from the last input value...
if last_input != input_val:
for i in range(input_val):
# if the level is lower...
if last_input > input_val:
for z in range(last_input):
# turn those pixels off
pixels[z] = (OFF)
# turn on pixels using the colors array
pixels[i] = (colors[i])
pixels.show()
# update last_input
last_input = input_val
time.sleep(0.01)
case
grid
strip-cover
back-cover
Download STLs.zip
https://adafru.it/Yef
Acrylic Template
Use the template to cut out the piece of
black LED acrylic. The dimensions are
listed in the template. Print the PDF and do
not scale.
acrylic-template.pdf
https://adafru.it/Yeg
acrylic-piece.svg
https://adafru.it/Yeh
Wiring
4-pin Cable
Use the 4-pin cable to connect the PDM
mic to the QT Py. This cable features
header pins that are not needed.
5V from NeoPixel – 5V on QT Py
GND from NeoPixel – GND on QT Py
DIN from NeoPixel – A0 on QT Py
Assembly
Installing QT Py
Get the QT Py ready to install onto the
strip cover. Orient the strip cover so the
built-in holder is lined up with the USB port
on the QT Py.
Final Build
Congratulations on your build! It's ready
for some audio input.