WEEK 2 (Embedded Programming)


In this week’s work, I created an LED set that coordinates with/responds to music and sound.
The device is prototyped on a breadboard and uses an ESP32-C3 microcontroller. It uses a microphone that outputs a value between 0 and 4,500, and is generally centered around 1,700 - 1,800 in the absence of significant noise. The microphone is read in through analong pin A1. The LEDs which respond to the music via the microcontroller are switched on through pins D0, D2, and D3. The image below shows the work:

The breadboard
Backup link: Breadboard Link


The technique used to control the LEDs is simple, and is based on amplitude of the sound. Specifically, we define a threshold, and if the sound - 1750 (which I identified as the mean sound in the absence of external noise) is above 1.0*threshold, we switch the red LED on. If the sound is between 0.9*threshold and 1.0*threshold we switch the yellow LED on. If the sound is between 0.8*threshold and 0.9*threshold we switch the green LED on. This is detailed more in the code here:



The ESP32-C3 code

The code is also included here as a downloadable file: Download LED - Sound Code A demonstration of this work has been done too. Using the Pirates of the Caribbean theme song, we achieve different patterns of LED lights.





Backup Video link: LED Flashing Lights (Play video with Volume!!!)


It tracks the music surprisingly well! More advanced techniques that may generalize better to more songs will likely use frequency analysis (perhaps a fourier transform) to control the LEDs. Download LED Sound Control file

The device can also be communicated with remotely. The threshold value we use in the code can be reset while the program runs. Future work will include doing this over Wifi instead of using a cable, and to use more advanced music processing techniques.





Adaptive Threshold Adjustment Backup Link: Remote Communication