Just read some comments to arduino and microphone and have a question.
Im just a beginner (and a girl) and Im trying to connect simple computer microphone with arduino. I need arduino to read it and tell my leds to dim.
My project is about lighting with microphone. when it’s quiet around the lamp lights are bright,when it’s loud they dim down.
could anyone help?
cheers :wink:


I suggest you break this problem into parts:

  1. Learn how to control the brightness of LEDs. For this you’ll need to connect the LED’s (with the proper resistors) to the PWM-capable pins of the Arduino, declare those pins as output and use analogWrite on those pins to control the output. There are plenty of LED tutorials around. =)

  2. Learn how to read the input from the microphone. I haven’t done this personally, but you’ll probably want to google around for a tutorial anyhow. To detect something you can probably just read it from an analog pin, but since an audio signal is not just a simple constant current voltage, it may require some trickery and/or extra hardware to do properly. Once you can read some kinds of sound levels from the microphone, first output them to the serial monitor to determine what values are the thresholds for levels you consider “loud” and “soft”.

  3. Combine the two, first something simple like:

const int LOUD = your_loud_threshold_value_here;
const int SOFT = your_quiet_threshold_value_here;

int soundLevel;
const byte LED_PIN = 11; // PWM pin for your LED
int brightness;

void setup () {
   pinMode(LED_PIN, OUTPUT);
   brightness = 128;
   // insert microphone initialisation code here

void loop () {
   // insert code to read microphone level into "soundLevel"

   if (soundLevel >= LOUD) {
      brightness -= 5;
      if (brightness < 0)
          brightness = 0;
   } else if (soundLevel <= SOFT) {
      brightness += 5;
      if (brightness > 255)
         brightness = 255;
   analogWrite(LED_PIN, brightness);
   delay(50); // adjust delay as desired 

Something along the lines of the above (untested, incomplete) code should (when augmented with microphone reading) brighten the LED gradually when the “quiet” threshold is not exceeded and dim it gradually when the “loud” threshold is exceeded. Once you have this working, you can start making the logic smarter (e.g. scale the value according to the level, not just increase/decrease at a constant rate), add more LEDs, etc.

I hope this helps a bit; this may not be the simplest project to start with, but certainly an educational one if you persevere. =)

thanks a lot,will try that :)

Hi there, I built the op-amp according to all info from


and used code for turning led on and off ith sound:

  1. /*
  2. * Monitor for sound sensor
  3. */
  4. int potPin = 2; // select the input pin for sound sensor
  5. int ledPin = 13; // select the pin for the LED
  6. int val = 0;
  7. int amp = 0;
  8. void setup() {
  9. pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
  10. }
  11. void loop() {
  12. val = analogRead(potPin);
  13. amp = (val >= 512) ? val - 512 : 512 - val;
  14. if (amp > 100) {
  15. digitalWrite(ledPin, HIGH);
  16. delay(20);
  17. }
  18. else {
  19. digitalWrite(ledPin, LOW);
  20. }
  21. }

it seems to work but there is not much connection between the volume and bightness of an led. I connected the positive cable to 5V power pin ,negative to Grnd pin and LED to Grnd pin and PWM10 pin. Also the sound values are very different and can't control them. I would like to set arduino to recognise 2 ranges of sound: normal quiet voice and loud voice/noise and react differently to them. To send more voltage when it's quiet and less hen it's loud.

Does anyone know what's wrong with my circuit and how to make it work? cheers

This thread seems to be about doing a very similar thing (and seems to have the same code you've got). Perhaps it might help (or maybe you've seen it already).


Thank you..I still have problems with this. I built op-amp like: but it makes lots of additional noise and I want it to control brightness of 18 LEDs acordingly to sound level surraunding the lamp. I know I need to add darlington array and resistors 82 Ohm but Im not really sure where to place them. Can anyone send me schematic for it please?