Sound sensitive lights w/ sound sensor & Arduino

Sound sensors can be used for a variety of things, one of them could be turning lights off and on by clapping. Today however we are going to use hook up the sound sensor to an array of LED lights which will beat with music, clapping or knocking.

Requirements

  • Almost any Arduino – I used the popular Arduino Uno
  • Some breadboard cables
  • A breadboard
  • A sound sensor – I used a high sensitivity sound detection sensor module by Keyes
  • At least 1 LED light – I used 7! The more the better!
  • As many LEDs you are using you should have resistors. 333 ohm resistors should do the trick for most LEDs but I used 100 ohm ones.

Connecting the sound sensor

The sound sensor should look something like this.

sound sensor

 

It has four pins that needs to be connected to your Arduino. The top one(if you look at the image above), is AO. This should be connected to the analog input 0 on the Arduino(A0). The one beside that is GND, which is connected to ground, the VCC is connected to +5V, and the last one is DO – which is the digital output of the module, and should be connected to digital pin 2 on the Arduino.

Here is the connection described with a table

Arduino Pin Sound Sensor Pins
A0 AO
GND  GND
5V VCC
Digital Pin 2  DO

 

On the top of the sound sensor is a little flathead screw you can turn to adjust the sensitivity and analog output of the sound sensor. To calibrate the sound sensor you can run some music the background and keep turning it until you start seeing the sensor-LED on the module starts blinking with the rhythm.

Connecting the LEDs

Now if you are only going to use one LED, connect your resistor from ground to the shorter side of the LED, and the long side of the LED to digital pin 3 on the Arduino.
If you have even more LEDs, keep doing the same but connect the next one to digital pin 4, the next one to digital pin 5 etc. I’ve written code to support 7 LED lights, which means you use digital pin 3 all the way to 9 for your LEDs. The reason I just didn’t connect the LEDs in parallel and then to only one digital pin, is because on for instance the Uno’s digital pins doesn’t have enough juice to fully power all those power hungry LEDs. You could use a transistor or a 7HC595N, but I just wanted to do a simple sound sensor tutorial so I didn’t include any of that in this post.

So basically Arduino Digital Pin(3-9) –> Positive Side of LED –> Negative Side of LED –> 333 ohm resistor –> Arduino Ground Pin(GND)

When its all connected it should look something like this

soundsensor2

Programming the Arduino

Below is the Arduino code. I don’t count on it to work instantly after uploading the code to your Arduino. It needs some calibration first. But first, copy the code to the Arduino software.

Now remove the all the comment-slashes which has ‘Serial’ commented out, for instance “Serial.begin(9600)” and “Serial.print(“Analog: “);”. When you did that upload the code to your Arduino. This will enable serial output which you can view by using the Serial Monitor from the Arduino software. You can open the Serial Monitor by going to Tools > Serial Monitor or pressing the magnifying glass-button in the Arduino software window. What prints out is the analog and digital values of from the sound sensor module. The analog value should spike up when a noise occurs and stabilize when it gets quiet again. Now in the code there is an “int threshold = 532;” line that needs to be changed to something very close but higher than the value you get from the Serial Monitor when it is quiet around you. For instance if you see an analog value of 253, then threshold should be changed to perhaps 255 or 257. When a sound occurs, the analog value will rise and go above the threshold value. When that happens your LEDs will turn on. When it gets quiet again the analog value will go back to 253 and the LEDs go dark again. When you think the calibration is finished, recomment the Serial-commands and reupload the code to your Arduino. Commenting out any Serial-commands is important due to the Serial commands take very much processing power from the Arduinos, and will affect the performance of the sound sensor and blinking.

You should now be finished!

Start some music and see the awesome lights blink with the beat of the sound!

 

If you have any questions feel free to ask me by using the Contact page or by commenting below.

Prince

A second year computer engineering student at Malmö University in Sweden just having some fun with this blog. Computer Engineering and Mobile IT: Bachelor of Science in engineering

You may also like...

47 Responses

  1. Simon says:

    Hello! I tried everything we can say but I clap very loud and strong to sound sensor can know it’s some voice. not working on music. :/

  2. Rizal says:

    Hallo !!! MrI programmed the sound sensors in the microcontroller arduino can not work, why yes sir.?
    Please please help her

  3. Ben says:

    My sensor is faulty right?

    The analog signal just never changes, or just changes by about 1-3 if i whistle. I just have the raw analog input being displayed so i cant be reading it wrong. The analog input changes when i turn the screw and ive moved it to just below whats needed to change the digital output but since sound doesnt seem to effect the reading i can never get it to change the digital output since it never reaches the threshold.

    • Ben says:

      I have to be reallyy loud for it to change just by 1 and even then it seems kinda random and not correct. Like if my base reading is 505, when i turn music on it will go from around 503(yup lower than normal) to about 506. So its kinda pointless

  4. sirine says:

    slt, je suis en train d’essayer de téléverser un code sur arduino mais je reçois ces erreurs. ya-til quelqu’un qui peut m’aider.. merci
    Arduino : 1.6.6 (Windows 7), Carte : “Arduino/Genuino Uno”
    Le croquis utilise 2 842 octets (8%) de l’espace de stockage de programmes. Le maximum est de 32 256 octets.
    Les variables globales utilisent 230 octets (11%) de mémoire dynamique, ce qui laisse 1 818 octets pour les variables locales. Le maximum est de 2 048 octets.
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    Problème de téléversement vers la carte. Voir http://www.arduino.cc/en/Guide/Troubleshooting#upload pour suggestions.
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x6e

  5. sirine says:

    slt, je suis en train d’essayer de téléverser un code sur arduino mais je reçois ces erreurs. ya-til quelqu’un qui peut m’aider.. merci
    Arduino : 1.6.6 (Windows 7), Carte : “Arduino/Genuino Uno”
    Le croquis utilise 2 842 octets (8%) de l’espace de stockage de programmes. Le maximum est de 32 256 octets.
    Les variables globales utilisent 230 octets (11%) de mémoire dynamique, ce qui laisse 1 818 octets pour les variables locales. Le maximum est de 2 048 octets.

    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    Problème de téléversement vers la carte. Voir http://www.arduino.cc/en/Guide/Troubleshooting#upload pour suggestions.
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x6e

  6. sirine says:

    slt, je suis en train d’essayer de téléverser un code sur arduino mais je reçois ces erreurs. ya-til quelqu’un qui peut m’aider.. merci
    Arduino : 1.6.6 (Windows 7), Carte : “Arduino/Genuino Uno”
    Le croquis utilise 2 842 octets (8%) de l’espace de stockage de programmes. Le maximum est de 32 256 octets.
    Les variables globales utilisent 230 octets (11%) de mémoire dynamique, ce qui laisse 1 818 octets pour les variables locales. Le maximum est de 2 048 octets.

    avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    Problème de téléversement vers la carte. Voir http://www.arduino.cc/en/Guide/Troubleshooting#upload pour suggestions.
    avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x6e
    avrdude: stk500_recv(): programmer is not responding
    avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x6e

  7. Jade says:

    Hi, what if the sound detector has only 3 pins? Out, Gnd, and Vcc only.

    • Prince says:

      If you google the sound detector model then you should find your answer. Either its digital or analog signal, but I’m willing to bet its analog.

  8. Igor says:

    Hi,
    I’m not able to see anything on the Serial Monitor for adjust that parameter you say, int tresthold = ???

    I’m just trying different values.

    Anyway, great job man. I’m totally newbie, and just starting learning programming so… Great.

    • Prince says:

      you need to uncomment the commands when calibrating the threshold.
      All Serial commands with “//” in front of them should have the slashes removed.

      For instance:
      //Serial.begin(9600);
      should look like:
      Serial.begin(9600);

      Remember to re-add the forward slashes again when done calibrating, and re upload the code.

  9. great project, please help me for send your circuit for my project dicky.yudha21@gmail.com. i wiss you can send your circuit for help me. thanks

  10. Silvio Pozza says:

    Sir, I am writing an article for my college about automatic lighting systems using Arduino, I would love to use your project as example, with all credits given to you. Is there any place where I can download your circuit schematics? Thank you very much.

  11. robert says:

    doesn’t work

  12. Demitri says:

    I don’t get any data in the serial monitor, but could adjust between the threshold command and the pot that is on my sound module.

    • Demitri says:

      I un-commented the serial lines. Why do they need to be commented back out after?

      • Liam says:

        It uses unnecessary processing power.

        • Prince says:

          Precisely. And also the serial buffer bogs down the reaction time. When I tried with serial on, the lights had a delay of about 300ms from when the sound was detected

  13. Demitri says:

    Fixed it.

  14. war1 says:

    this microphone is faulty people. it needs an amplifier.. buy microphone with 3 pins, they have amplifier on them….

    i tried, and even adjust the internal potentiometer.. it does not detect sound… it may vary by itself…

  15. Dj Kraken says:

    Hi, How i can make that flashes according to a frequence, say low mid and hi.

  16. Dom Sampays says:

    Should I want the amount of lit LED’s to depend on volume would this just be a case of coding several thresholds? Also would it be the same principal with led strips? I am attempting to make a mask where the mouth lights up depending on sound level for a festival, would this mic be ok with very loud music? Attempting to make something along these lines, but the mouth behaving almost like a one channel equa’iser… http://technabob.com/blog/wp-content/uploads/2014/07/Sound-Reactive-LED-DJ-Mask-620×620.jpg

  17. sasikumar says:

    Dear sir,
    when i run this code i am getting the analog value as 85 and digital value as 0 but even when i am playing music the value is not changing so pls help me.

  18. Eric says:

    I took out the slashes but nothing appeared. Can it be because my sensor is linked to the breadboard?

  19. thazin says:

    Because of implement sound sensitive light

  20. steve says:

    how i want to connect the arduino nano with sound sensor the connect to lcd.

  21. Showan says:

    When I open the serial moniter nothing shows. What shouldI do?

  22. Kelvin George says:

    I want to use three sound sensor in one arduino uno is it possible? if yes how can I program it?

  23. Somair Taj says:

    One thing he does not state or show in his picture is that the resistors needs to be connected to the ground on the arduino board. Run a wire connection from one of the spots in the “-” channel on the bread board to the 2nd ground spot on the arduino.

    You can test to see if the lights and everything are hooked up by reversing the sign in (sensorvalue >= threshold) to (sensorvalue <= threshold). All your lights should be lit without having to worry about the sound sensor.

  24. Domenico Lecchino says:

    Hi there, is there a way i can use no breadboard and make it by soldering the components needed? Also is there any schematic for this so it’s easier for people like me who are need to this and need to follow from a schematic?

  25. John Martin says:

    A pretty comprehensive and somewhat damning review of what appears to be the same sensor can be found here http://www.axino-tech.co.nz/documents/duinotech%20microphone%20sound%20detector.html the person who did it clearly knows a lot more than I do, but based on my personal experience and the comments here, it appears that adjusting the potentiometer really only helps with the trigger point for the digital output and does pretty much nothing for the actual sensitivity of the analog output. In effect the analog output is useless for most of the things you’d probably want to use it for.

  26. Yosr says:

    hi ,
    i want detect the frequency using this module ,can u help me please .
    thank u in advance

  27. fatima says:

    I’ve got a project audio detector using the integrated 555 transistor and did not know how to do it

  28. Tyler Scott says:

    hi I’ve made this project exactly but the serial monitor is showing analog:1023 and digital:1—i don’t know what to do and its not detecting the sound ?

  29. Billy Bob Joe says:

    Is this detecting specific noises or just from a certain volume?

  30. Alex Liu says:

    I think it’s >== not >= because when it is >= it adjusts to the previous sound making it light up all the time.

  1. 09/10/2014

    […] These two projects are most interesting to me. So, for this exercise I will try to somehow combine two projects: the Led Strip Lights and the Sound sensitive lights with sound sensor & Arduino. […]

  2. 09/25/2014

    […] Drop The Bass! Project used the same principles of  the Princetonic’s Sound Sensitive Lights, but I used a microphone sensor that was not high sensitive and just has an analog Input. Also I […]

  3. 11/15/2014
  4. 11/15/2014
  5. 04/12/2015
  6. 04/16/2015
  7. 04/22/2015
  8. 09/29/2015

    […] I simply followed this tutorial, Sound sensitive lights w/ sound sensor & Arduino […]

Leave a Reply

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

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