Electret Microphone to control LED

Hi, new to the Arduino scene, I am looking to connect a Due or Uno to a electrolet microphone and 20-30 RGB LEDs that would cycle through their spectrum of colors based on the volume of music being played. I would also have several yellow LEDs that would constantly be on. The volume would be read in by an electret mic.

Just looking to check the feasibility of this project before I begin to purchase materials.

Any feedback or recommendations would be much appreciated!

that would cycle through their spectrum of colors based on the volume of music being played.

So do you want to lit the rgb leds based on the music volume, not based on the music frequency band spectrum (like light organ)?

Right, I just want them to light up and change colors based on volume.

So you need: 1. MIC :) 2. amplifier (transistor or opamp based) - NOT needed if the MIC has a 100x amplifier built in 3. envelope detector 4. connect 3. to an analog input, and 5. based on the reading do control the pwm of the particular LED. Fully feasible..

The electorlet mic has a built in op amp!


PS @OP links to hardware you are using avoids confusion!


The electorlet mic has a built in op amp!

electorlet - I thought it is a typo…

I'm looking at this mic, it has a 100x op-amp built in!


HAHAHA... I thought you had a typo as well.. .but indeed it would appear that the rest of us need to remember what SparkFun has to offer.

I do have something slightly useful to add. I am also going to be doing this as an add on to a system I am working on now, but if your needing help for ideas on how to construct this and program it. There are a very large number of people who have made more or less exactly what you want, and have posted build threads and code to do it. Google is your friend I will not bother to post the results for you but much of what you likely want to know is at your fingertips.

I will be ordering the same "electret" microphone myself once I figure out if my current project works well enough to add on to it without increasing trouble shooting burden.

GOOD LUCK. This is a fun project.

This is why me tell you to post links to hardware!!!


A simple envelope detector with a diode - use schottky or better, a germanium one.

An example: Envelop detector with an opamp

You can probably ignore the envelope detector and just read the peaks. Peaks don't correlate well with perceived loudness, but for a lighting effect peaks are fine.

I'd break the project into two parts -

1. Loudness detection. The SparkFun board is biased at 2.5V. This is done because audio is AC, but the Arduio cannot accept negative voltages (such as the negative half of AC). You'll need to adjust for that in software... You can subtract the bias (i.e. subtract 512 from the ADC reading), or you can ignore negative readings.

To begin with, I suggest making something that simply turns the LED on when the loudness is above a certian threshold. (You can use the built-in pin-13 LED.)

For sound-activated lighting effects, I like to save a reading every second or so, and make a 20-second [u]moving average[/u], and use that as a reference. That way my effects automatically adjust to volume changes. A very-simple automatically-calibrated "flickering effect" is to compare the input to the moving average and turn the led on whenever the signal is above average. I've also made a VU-Meter like effect where the bottom LED is calibrated to "average", and the top LED is calibrated to the the peak in my moving-averaging array. Note that the true average of an audio signal is zero... So, you need to average just the positive readings (or readings above 512), or the absolute value after subtracting the bias.

2. LED driver circuit. 20 RGB LEDs requires 60 outputs/connections. You'll need some sort of driver circuitry. I've used some serially driven LED drivers to individually "address" 48 LEDs. (Soldering 48 single-color LEDs was LOT of soldering!) The chips I used aren't really for RGB LED, so I won't recommend it. You'll need to search for an appropriate driver chip. You'll also need to consider if you need to dim the LED outputs (for "infinite" color combinations).

Again, I'd start simple, with maybe one RGB LED. Once you can program one RGB LED, you should be able to add/control more.

The above sounds good (sorry but), yes split things to three

  1. reading the inputs

  2. the outputs

  3. the code in-between to transform the inputs to outputs.

But really that’s a good discription of any project!


Would it be possible to use this solution and be able to tell the difference between Bass and Treble? I am trying to do almost the same thing but would like to tell the difference between bass and treble and I'll only be using 3 leds, for this project.

Sorry for hijacking this post its been the closest thing to a solution I've seen so far.

Maybe if you use 2 analog inputs with a high pass filter to get the treble and a low pass for the bass.


Hi Mark,

Thanks for the reply greatly appreciated! I'm researching filters now (low and high) such as bandpass.

Sincerely, Michael

I am having trouble with my code also , i am trying to use bitVoicer to light up an LED and it just doesn’t seem to be working , any ideas?

#include <BitVoicer11.h>

//Instantiates the BitVoicerSerial class
BitVoicerSerial bvSerial = BitVoicerSerial();

//Stores true if the Audio Streaming Calibration tool
//is running
boolean sampleTest = false;
//Stores the data type retrieved by getData()
byte dataType = 0;

int ledRED = 3;
int lightLevel = 0;

void setup()
//Sets the analog reference to external (AREF pin)
//WARNING!!! If anything is conected to the AREF pin,
//this function MUST be called first. Otherwise, it will
//damage the board.
//Sets up the microcontroller to perform faster analog reads
//on the specified pin
//Starts serial communication at 115200 bps
//Sets up the pinModes
pinMode(ledRED, OUTPUT);
//pinMode(pinY, OUTPUT);
//pinMode(pinG, OUTPUT);

void loop()
//Captures audio and sends it to BitVoicer if the Audio
//Streaming Calibration Tool is running
if (sampleTest == true)
//The value passed to the function is the time
//(in microseconds) that the function has to wait before
//performing the reading. It is used to achieve about
//8000 readings per second.

//Captures audio and sends it to BitVoicer if the Speech
//Recognition Engine is running
if (bvSerial.engineRunning)
//The value passed to the function is the time
//(in microseconds) that the function has to wait before
//performing the reading. It is used to achieve about
//8000 readings per second.

//This function runs every time serial data is available
//in the serial buffer after a loop
void serialEvent()
//Reads the serial buffer and stores the received data type
dataType = bvSerial.getData();

//Changes the value of sampleTest if the received data was
//the start/stop sampling command
if (dataType == BV_COMMAND)
sampleTest = bvSerial.cmdData;

//Signals BitVoicer’s Speech Recognition Engine to start
//listening to audio streams after the engineRunning status
//was received
if (dataType == BV_STATUS && bvSerial.engineRunning == true)

//Checks if the data type is the same as the one in the
//Voice Schema
if (dataType == BV_STR)

void redLEDS()
if (bvSerial.strData == “red”)
digitalWrite(ledRED, HIGH);
lightLevel = 255;
digitalWrite(ledRED, HIGH);
lightLevel = 0;