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().

33 Comments Add yours
  1. Hey mate,
    great stuff! I got same sensor from eBay. Care to share the code for this lttle project?
    Thanks!

  2. 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. 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. 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. 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! 🙂

  6. 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?

    valeu.
    see ya

  7. 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?

  8. 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 🙁

  9. 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?

    1. 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.

  10. 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

  11. 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()
    {
    Serial.begin(9600);
    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);
    if(i<=5)
    {
    analogWrite(8, LOW);
    analogWrite(9, LOW);
    analogWrite(10, LOW);
    }
    }
    }

  12. 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 ?

  13. 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??

  14. 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!

Leave a Reply

Your email address will not be published. Required fields are marked *