Arduino + Sound Sensor

I got a sound sensor on Ebay some days ago, and decided to give it a try!
Really simple, just made a code to light up the led when the volume was higher than the ambient sound.

Just for fun! 😉

As many people have asked, here goes the code:

Remember that there are many other ways of doing this, for example using the PWM function along with analogRead() and map().

34 comments on “Arduino + Sound Sensor

  1. Sauli May 29, 2011 1:07 pm

    Hey mate,
    great stuff! I got same sensor from eBay. Care to share the code for this lttle project?

  2. Pedro September 10, 2011 3:58 pm

    Hi Daniel!! I really like this experiment you did. I think that it would be useful for a DiskJoker, making a tool display panel with visual effects.

    Which is the name of this sensor? What version of arduino are you using?

  3. Jiang Ying dao November 14, 2011 2:01 am

    Hi Danite !
    I’m come from china and stuy in Kroean university . …
    I really like this project which you did. I want to know what version of arduino are you using ?
    could you send the arduino code to me …and show me your step clearly… I want to make it like you did .
    please….. I really want ….

  4. Isiah Heart November 17, 2011 1:04 am

    Hi Daniel
    I really love this project and i would like to try it myself it would really help me out significantly if you can share your code with me and maybe show me on a step by step basis how you executed this project. Thanks for showing this wonderful project and if you can help it will be much appreciated thanks so much

  5. Oliver Kapffer December 10, 2011 2:49 pm


    I’m interested in the code too, so please post!


  6. DanielAndrade December 10, 2011 6:37 pm

    I don’t have the code anymore, but it was something like this!

    You analyze the Analog reading then, if the sound is louder then some value, it
    turns the LED ON, otherwise OFF.

    Got it? Anything just say! 🙂

  7. Steve July 4, 2012 11:04 am


    Great project. I am looking for a sensor for a similar project and wonder if you could tell me what you used.


  8. paulo varella August 9, 2012 1:06 am

    Ola daniel, eu acabei de receber este sensor, e minha ideia e ativar um servo com o som.
    Se eu usa seu codigo ao inves do led , daria certo com o servo?

    see ya

    • DanielAndrade August 9, 2012 10:18 am

      Com certeza!
      Só terá que interpretar melhor o código ou montar um algorítmo para ler o sensor e alterar o motor.


  9. diego September 11, 2012 12:06 am

    Ola, onde encontro este sensor para comprar e qual o preco ?

  10. Emanuel Setio Dewo October 3, 2012 1:55 am

    Hi. This is a cool project.
    Can this sensor recognize specific sound? to recognize flap for example?

  11. César Fernández Ortega June 6, 2013 11:01 pm

    Hi, I’m interesed in the code too, please if you can post it, thanks …César

    • dansku June 7, 2013 9:02 am

      Just posted the code 🙂

  12. Juelz HD November 18, 2013 5:31 pm

    Hey man thank you soooooo much im soooo freakin glad i found this video you posted and the code!!! ahhh saved my art project. Would you know by any chance how to tweak this code to emit a brighter LED with louder sound and dimmer LED with lower sound?

  13. Damiano December 5, 2013 6:48 pm

    Hi can you please tell more about the circuit please? thanks about the code

  14. Asha Di January 31, 2014 2:38 pm

    HI Daniel, may i ask what’s the name of the sensor and the USB LED light? i searched on ebay, didn’t find any similar thing 🙁

  15. throwhammer . April 24, 2014 6:37 pm

    When I plug my sound sensor into the 5v pin on my arduino board the board stops working… Pi thought the USB connection would still power it? Any help please?

    • throwhammer . April 24, 2014 7:49 pm

      Sorted that problem out now but my sound sensor will only read a value of 1023 even if there is total silence. Any help please?? Thank you.

      • somenzi June 6, 2015 1:17 pm

        same to me… =(

        • throwhammer . June 6, 2015 5:26 pm

          You need to turn the small screw on the sensor board to calibrate it

  16. Richard December 31, 2014 5:55 pm

    Hi there,
    Thanks for the code.
    It took some puzzling before i found out that the DigitalWrite(Led,High) actually turns of the led when i use my sound sensor. When the high and low were changed it worked as a charm.

    Thanks, Richard

  17. Matthew S. February 12, 2015 3:51 pm

    This is for the arduino Mega only
    This was made for sound reaction however it’s not perfect although better than the ops code
    I use this to control a led strip using a low signal amplifier using tip-31 transister to control all three channels R,G,B to glow white although the color would need adjusting.
    const int CPin = 2; //MEGA PIN 21 (INTERRUPT PIN 2)
    int outputValue = 0;

    void setup()
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
    attachInterrupt(CPin, new_data, FALLING);

    void loop()

    void new_data()
    pnter(map(analogRead(CPin), 0, 760, 0, 255));
    //Serial.println(“Sig-DN: ” + String(outputValue));

    void pnter(int val)
    for(int i=50;i>0;i-= val / 50)
    analogWrite(8, i);
    analogWrite(9, i);
    analogWrite(10, i);
    analogWrite(8, LOW);
    analogWrite(9, LOW);
    analogWrite(10, LOW);

  18. AS SH March 1, 2015 3:07 pm

    Hi, Thanks for sharing the code!
    I had one problem when trying it though, the led is always on and the analog values of the sensor is always 1023.
    Any advices ?

    • Daniel Andrade June 6, 2015 9:06 pm

      You can try changing the value of the potentiometer!

  19. Robert July 2, 2015 5:19 pm

    Hey, my sensor always gives me 1023 as value, no matter what I do. Any ideas why?

  20. angel February 17, 2016 7:00 pm

    quisiera saber si este micrófono me sirve paras utilizarlo para un sonometro el cual estoy realizando para un proyecto pero no encuentro como tal uno que se adapte a mi necesidad sera que me puede ayudar??

  21. Ricardo M. Augusto May 16, 2016 10:10 pm

    Could you share what sound detector you have used ? Thanks

    • dansku May 30, 2016 4:32 am

      It’s any sound sensor you can find on eBay. I don’t remember this specific one, as I did it long ago.

  22. Benjamin Thorkelson June 25, 2016 6:10 pm

    Hello Daniel,

    This is my first time using an Arduino, so this was fantastic! Thank you! I bought a set of Keyes LED’s that I would like to hook up to my Arduino Micro to have the same effects as what you have done, but the Keyes LED’s have the ability to be green, red and blue. Is there a way to make it so that the type of sound activates a different color on the LED? I know you mentioned the PWM function in a previous comment for changing the brightness of the LED, would that work on this as well? Any help is appreciated! Thank you in advance!

  23. sahil sharma February 28, 2017 6:47 am

    I am sahil
    I have a doubt
    how to connect sound sensor to the aurduino uno and led
    plz tell me

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.