Musical note-detecting light display

Make a low-cost, low-power light show responsive to specific musical notes present in ambient sound.

Similar projects worth following
The purpose of this project was to create low-cost devices for art or music installations. Each device is a 1" diameter PCB that includes a small microphone and a tricolor LED. It's "tuned" to detect a single musical note (software-selectable anywhere between C2 (65.4Hz) and C6 (1046.5Hz)), and it lights up the LED with brightness proportional to the sound amplitude of the detected musical note. The LED color "drifts" slowly between randomized points on the color wheel.

By programming several of these devices to different musical notes, you can make a light-up array that responds to music!

Each device runs off of a CR2032 coin cell. When no sound is detected, the device enters sleep mode, during which it consumes ~1.5uA of current. It periodically wakes up and samples audio and stays on if the note is detected.

Current medium-quantity unit costs are ~$3.25USD for the PCB, components, and assembly (not including the coin cell). I'm hoping to g

Note: check out the prototype demos, I've attached the videos to this page, and the videos are also posted on Imgur:

Project Summary

This project outlines the hardware and embedded software design of a coin-cell powered circuit that samples ambient sound and lights up a tricolor LED when a specific musical note is detected. The LED color randomly changes over time, and the brightness of the LED is proportional to volume detected at the specified note frequency.

Project Inspiration

At a local art convention I met someone selling outdoor lamps consisting of used bottles with LED string lights powered off of small solar cells. The solar-powered string lights were purchased in bulk from an online seller, allowing this artist to focus on her project's aesthetics without having to worry about circuitry.

I wanted to design a kit in the same spirit: something low-cost, low-power, ordered in bulk, "just works" out of the box, that an artist can use without any technical knowledge. I also wanted to make something responsive to the environment: in this case, ambient sound.

I imagine a scenario in which of dozens of these devices are decorated, housed, or otherwise embedded into some workpiece, lighting up in synchrony with songs or speech.

My goal is to sell batches of these devices online at cost (maybe grouped by musical octaves), once I get the unit price down a little bit more.

Hardware Overview

The 2-layer circular PCB has a 25mm diameter. One side holds the (electret condenser) microphone and the RGB LED. The other side holds the analog filter/gain stage, microcontroller, and the coin cell holder, which covers most of the other components. Low-cost, electret condenser mics consume current in the ~100's of uA, so the entire analog front end is powered down during sleep mode and periodically turned on to sample for the target frequency.

I chose an electret condenser mic because they were slightly cheaper than MEMS microphones. However, they can be interchanged, and if I find a similarly-priced MEMS with lower power consumption, I will probably do so. For MEMS microphones with pulse-density modulation output, some extra filtering will be needed on the front end of the analog gain stage.

I've designed a batch programming board with alignment pins and pogo pins for flashing the embedded code to each board. I intend to make a small enclosure/jig for this board to streamline the process. This board serves only as a break-out board for the programming header.

Firmware Overview

For more detailed notes on the firmware, see firmware/ on the Github page.

The firmware implements an ADC sampling scheme that allows for simple single-bin DFT processing. By sampling at 4 times the frequency of interest, you can calculate a DFT with simple addition and subtraction, no trig functions or floating point math needed. Once the real/imaginary terms are accumulated from the raw sample values, I use pow() and log() implemented with integer math and lookup tables to bypass having to use sqrt() or any floating point multiplication/division.

The calculated signal amplitude is used to determine the PWM values driving the LED's. The color is picked with a random number generator using a hue/saturation/value color scheme, and the RGB values are calculated with an HSV-to-RBG module that uses only 8- and 16-bit integer math. The color is slowly "ramped" to another randomly chosen hue/saturation, while value (brightness) is locked to the sound amplitude.

If the sound amplitude is below a certain threshold for too long, the device enters sleep mode. It periodically wakes up to sample audio. One of my work-in-progress tasks is determining appropriate threshold levels (which will vary across target audio frequencies) and appropriate timing to wake the device to poll ambient sound. The challenge is finding the right balances between power consumption, device responsiveness, and volume sensitivity....

Read more »


Here's with the board programmed to detect E4 (329.6Hz). I covered the LED with a small square of paper towel as a makeshift way to diffuse the light. At the end I play the same note so that it's easier to see the output color "drift" across the color wheel. (Using the virtual piano from

quicktime - 16.61 MB - 03/20/2023 at 08:15



With the board programmed to detect G5 (392Hz), I play the adjacent (half and whole tones) to demonstrate the selectivity of the single-bin DFT filter. (Using the virtual piano from

quicktime - 10.91 MB - 03/20/2023 at 08:15



The board programmed to detect C3 (130.8Hz), but the filter components analog portion are selected for higher octaves (there is an alternative BOM for notes below C4). As a result I had to decrease the "cutoff" amplitude in the firmware, but I include this here just as a demonstration.

quicktime - 8.79 MB - 03/20/2023 at 08:15


  • 1
    Hardware assembly

    The Github repository includes the KiCAD design files, which you can use to order the PCB and bill of materials. All of the components are surface-mount except for the CR2032 battery holder. Take care when mounting the microphone, as it can be damaged by excessive heat.

    The CR2032 battery holder blocks the programming contacts/pads, so don't install this until after you've programmed the microcontroller!

  • 2
    Flashing the firmware

    The firmware can be compiled and programmed using the MPLAB X IDE in conjunction with a programmer that supports this microcontroller, such as the ICD4 or the PICKit4 (I have not confirmed support for the PICKit4!).

    The PCB has surface-mount pads for accessing the In-Circuit Serial Debugging (ICSP) pins on the PIC18. The Github repository also includes the design files for a programming break-out board with pogo pins and alignment pins. This can be connected to a Microchip ICSP programmer/debugger to flash the microcontroller.

  • 3
    Substituting a microcontroller

    As of now the only supported microcontroller is the PIC18F06Q41. If you substitute another microcontroller, implement the functions declared in the h-files in the HAL directory. Depending on your choice of microcontroller, you may need to run the SignalSamplingConfigurator Python script. Define your microcontroller's peripheral timer speeds, and the script will output the appropriate settings for each musical note.

View all 4 instructions

Enjoy this project?



Matt wrote 03/31/2023 at 03:34 point


  Are you sure? yes | no

Matt wrote 03/25/2023 at 00:25 point

Just edited the project description, I wasn't sure how obvious it was that each device is tuned to a specific note, and not just a general volume-detecting meter.

  Are you sure? yes | no

Matt wrote 03/21/2023 at 16:58 point

Now that I have the proof-of-concept working and have a better idea about the embedded memory requirements, I can switch to a cheaper microcontroller. Pricing for the PIC18F06 (64k flash + 4k RAM) is $1.24 at mid-range quantities. I only need 16k flash and 1k RAM, so I think it's reasonable to expect to be able to find something that costs less than half as much..??

I'd like to find a cheaper microphone too (current price is $0.58/each), but I will have to search outside of Mouser and Digikey to do so. Any advice would be appreciated. I see attractive prices on Alibaba, but I haven't gone that route before, and I don't know what to expect as far as reliability.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates