
This project makes use of Seeedstudio's Grove Sound Sensor. Which essentially gives your Arduino ears ! The small sound sensor (microphone) attaches to an Analog pin on the Arduino and can be used to detect the level of noise in the surrounding environment. You could potentially use this sensor to turn a light on in your house after recognising a specific clap/whistle sequence. In this tutorial we are going to connect a few LEDs to the Arduino, and get it to listen for a click/clap, and respond accordingly. Have a look at the video below for this project in Action.


Parts Required
- Arduino UNO or compatible
- Grove Sound Sensor
- Grove - Base Shield
- Protoshield
- Headers
- LEDs and 330ohm resistors
- Mini Breadboard 4.5cm x 3.5cm
- Grove Universal 4 Pin Cable
- Breadboard Jumper Wire

Assembly
- Place the Grove Base shield onto the Arduino UNO or compatible microcontroller.
- Solder some headers onto a ProtoBoard and then stack this onto the Grove Base Shield
- Stick a Mini-Bread board onto the ProtoBoard.
- Get 3 LEDs and 330 ohm resistors, connect to Pins 3, 5 and 6, and
then to Ground
- Attach the Sound Sensor to the Grove Base Shield A0 clip (next to shield's reset button)

Sketch



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
/* ======================================================= ArduinoBasics: Sound Sensor: Written by ScottC 8th May 2013 ==========================================================*/ int soundSensorPin=A0; int soundReading=0; int soundThreshold=500; int intensity[3]={0,0,0}; int LEDPins[3] = {3,5,6}; int numberOfPins=3; int currentPin=0; int fadeCounter=0; int fadeDelay=50; boolean switcher = true; void setup(){ pinMode(soundSensorPin, INPUT); for(int i=0; i<numberOfPins;i++){ pinMode(LEDPins[i],OUTPUT); } } void loop(){ soundReading=analogRead(soundSensorPin); if(soundReading>soundThreshold){ if(switcher){ aboveThreshold(currentPin); switcher=true; } } else { if(switcher){ belowThreshold(); switcher=true; } } } void aboveThreshold(int cPin){ switcher=false; if(intensity[cPin]<10){ intensity[cPin]=255; delay(50); currentPin=currentPin+1; } if(currentPin==numberOfPins){ currentPin=0; } } void belowThreshold(){ switcher=false; fadeCounter++; if(fadeCounter==fadeDelay){ fadeCounter=0; for(int i=0; i<numberOfPins;i++){ analogWrite(LEDPins[i],intensity[i]); } for(int i=0; i<numberOfPins;i++){ intensity[i]--; if(intensity[i]<0){ intensity[i]=0; } } } } |
how i can connect Grove universal 4 pin cable if i don't have grove - base shield
ReplyDeletethanks
SIG (yellow wire) to Analog 0 pin.
DeleteVCC (red wire) to 5v
GND (black wire) to Ground (GND)
White wire is not used.
can you give the circuit diagram of this?
ReplyDeleteHi there so i have this project and know nothing about coding... I need a cat toy to go off when my cat starts meowing(at 5 in the morning). this is the cats toy.. https://www.getcatsmeow.ca/ i have replaced its motor with a 9v so its a little bit more challenging for my cat. and i have it running on a 9v ac power adapter.. I bought this sound sensor on ebay.. http://www.ebay.com/bhp/sound-sensor-module.. it seems to be the same set up as the one you suggested.. I just dont know a thing about coding to get this working.. if you could help out at all that would be awesome.. thanks so much!
ReplyDeletesorry i am also a graphic designer and if you would like to trade code for maybe a logo or a new layout for your blog i would be more than willing to hook you up! thanks in advance!
ReplyDeletemy email is jadonv11@gmail.com
ReplyDeleteHi Jadon,
DeleteContact me via youtube, and I'll see what I can do.
Hi Scott, Do you have the circuit schematic for the project? I would buid the project but without the grove base shield and protoshield just to see if it can be compensated just using jumpers..
ReplyDeletethank you in advance
Hi Beswan,
DeleteYou can definitely use this sensor by using jumper wires.
The LEDs are attached to digital pins 3,5 and 6. Each with their own resistor, and then to ground.
The Sound sensor has 4 connection points, however one of them is not used.
Black wire = ground
Red wire = 5v
White wire = not used.
Yellow wire = Connected to Analog pin 0.
I would still recommend getting the Grove universal 4 pin cable to connect to the sensor, and then cut the other connector off so that you can easily attach the cable to the relevant pins on the Arduino board.
Hi, would you be able to use this to detect sound and then play a pre- recorded voice as well as an LED? Thanks
ReplyDeleteJack,
DeleteYes it is possible. However note that you would need the appropriate outputs in addition to the items described in this project.
You could use your computer and the processing language to play a sound file or movie file, or you could find some other way to play the sound, and the illumination of the LED is already displayed in this project.
hallo
ReplyDeleteam clemo,i saw ur clip on youtube about anttiny 85
,i was wondering u may help me out with a project programming using attiny45
i wanna make clap switch
operation=clap twice on clap twice off
Can u help me with code that needed for the project?
Hi Clement,
DeleteI don't have an attiny85 - you must have mistaken me for someone else.
My clip from youtube is shown above.
Scott
How would I use a fast fourier transfer to identify a whistle pattern and then activate an LED? I'm at a road block and needs help badly.
ReplyDeleteHi Joseph,This question is for the forums. Have never dealt with fast fourier transfer algorithms.
DeleteThis site may help you on your path
DeleteHow would I be able to use the sound sensor to pick up high sounds ( police siren), and turn on or make an LED start flashing once the sound is heard? The important thing here is for the LED to not go off when normal sounds ( speech or clapping) is heard. Thanks
ReplyDeleteand any hints or helpful tips about coding it? or any actual code haha
DeleteI don't think it discriminates between different frequencies.
DeleteDo you have a code for Arduino sound detection sensor tk0862 ?
ReplyDeleteSorry - I don't. I only have code for the sound sensor mentioned above.
Deletehey can i use this circuit to detect the crying of babies?
ReplyDeleteIt will not discriminate between a baby and any other loud noise. But I guess you could get it to alert you when there is ongoing loud noise. As the noise gets louder the voltage changes. So the answer is yes, but only to the extent described above.
Deletesorry, may I know how about this sensor program when we use atmega32 and bascom language?
ReplyDeletethank's before :)
Hi Janur,
DeleteI have never heard of the bascom language - sorry.
Any reason why you don't want to use the Arduino IDE? It's free !!
Hi Scott, Can you tell me how to connect microcondensor directly to mikrokontroler arduino? I just need to read the voltage of the frequency. maybe you have the code for arduino. please tell me by email . thanks scott. i would appreciate it.
ReplyDeleteHi MMC,
DeleteHave you seen this tutorial?
http://www.arduino-hacks.com/arduino-vu-meter-lm386electret-microphone-condenser/
I have never used a micro condenser on it's own. Sorry.
sir can i have the schematic diagram of this? I need this sir for my undergrad. thesis.. pls reply sir
ReplyDeleteI did not do a schematic diagram for this project.
DeleteBut should be easy for you to create one in Fritzing (if required).
Sir can I adjust the volume or the loudness that it can receive???....because I will make an prototype that measure a sound or voice level that when the sound reach it's maximum decibel it will trigger the buzzer or the camera?
ReplyDeleteI have never tried to adjust the sensitivity of the sensor, but I guess that is what the potentiometer is there for - I am not certain about this, because I have not checked.. But it can differentiate a loud noise from a soft one. The analog reading will change depending on how loud the sound is, and you could use this fact to only trigger when the analog reading reaches above a certain level.
DeleteI wrote a MATLAB script interfacing my laptop's inbuilt microphone to calculate the dbA levels of noise in my classroom. (un-calibrated, as of now)
ReplyDeleteI want to now use this dbA calculation script on data from my arduino. (Electret Microphone Amplifier 4466). I want know what is the difference in the 2 inputs and what changes I should make in acquiring my data from the arduino to receive the same result as I did with the inbuilt microphone.
I have no idea... I have never used MATLAB.
Deletegoodmorning sir, actually im going to create a project and one of its function is to detect the crying sound of the baby.. and one of my big problem is that i dont know what sensor to be use. can u help me :) thankyou sir
ReplyDeleteThis product is pretty much over priced and useless since it's best use requires you buy a cable, build a shield to make it work properly total ripoff
ReplyDeleteHi Anonymous,
DeleteYes - the grove cable makes it easier to connect to the module, and the Grove Base shield makes it easier to interface with the Arduino, however, neither are compulsory. You could just connect the module directly to the Arduino without the shield. In fact, you could even use this module without an Arduino. But I must say that there aren't many modules out there that don't require you to buy a cable or wire of some sort.. that is just the reality of working with modules.
I don't agree that it is useless... in fact I found this module to be very reliable, and works just as I expected it to... much better than some of the "cheaper" stuff you can buy elsewhere. I don't think that it is over-priced either... a good module for less than $5... I don't regret paying that amount for something that works well, and has some solid information from the manufacturer to get you up and running in next to no time: http://www.seeedstudio.com/wiki/Grove_-_Sound_Sensor. What you save on the cost of a cheaper module, you lose on the amount of time trying to figure out how to use it (providing it works).
I guess I disagree with everything in your comment.
But that is ok, we can agree to disagree :)
hi scott
ReplyDeletei am working on project, where i want to detect cry/shout of an adult (human).Does it possible? if yes then, what hardware are required? i have microphone , arduino nano. i am having problem with cry detection using these hardwares? actually i want to differentiate bewteen other loud sound and human cry. please HELP ME.thanks in advance
I don't know how you would differentiate between other loud sounds and a human cry? You would have to have some way of analysing the different frequencies... similar to speech recognition. And that, I'm sorry to say, is beyond my level of knowledge.
DeleteScott!
ReplyDeletewhat if i want to recognize single words like FOOD , WATER , SlEEP and send a signal to android app through HC 05? Does it possible with Arduino? and else hardware are required? Help me.
Hi Zeeshan - this also would require some sort of analysis of the sound signals... and as mentioned previously - is beyond my level of knowledge. There may be a module out there that can handle the speech recognition processing required ... but I have not come across it yet.
Deletescott- Do you know anyone who can help me in that!
ReplyDeleteZeeshan - your best bet is likely to be the Arduino forum
DeleteHey, so this is a sound sensor which beeps/flashes if the sound level is above a certain threshold. But can we modify it to make a sound detector( as in which could distinguish different voices) ?
ReplyDeleteNo - it does not detect different frequencies.
DeleteThis particular sensor detects decibels.
Hi, I'm working on a similar set-up at the moment. I'm just wondering, when the threshold is set, what is the number representing? I left my threshold 'open' so to speak and detected the ambient sounds surrounding me. I then set the threshold to '100' and clapped to detect a loud sound. What does the '100' or '500' or wahatever value I set, actually represent?
ReplyDeleteThe sensor converts decibels to voltage.
DeleteSo louder sounds will produce higher voltages.
The analog pin in this project will detect from 0 to 5V. But these are represented by readings from 0 to 1023.
A reading of 1023 = 5V
A reading of 0 = 0V
So you essentially set a "volume" threshold between 0 and 1023.
And use that threshold to direct the flow of code.
Thank you very much! You just helped me out a lot. Much appreciated.
DeleteIs there any computation on how to know what exactly voltage am I having?
Delete(Analog reading / 1023) x 5
DeleteHi, Sorry, just another question, what is the dB range of the sensor? what is the max dB it can detect?
ReplyDeleteI don't know.
DeleteHello Scott, thanks for sharing this post! I have a question. Is it possible for me to attach more than 1 Grove sound sensor (ideally 4 sound sensors)?
ReplyDeleteof course you can. You just have to modify the program.
DeleteThat's great! Thank you for the reply!
ReplyDeleteDoes the coding change if you use it on an electric fan?
ReplyDeleteyes - because there are 3 leds, but you are using one fan, so you would have to make the necessary changes there.
DeleteCan you help me with the code in assembly language for a sound sensor in interfacing blinking LEDS using parallel port. This is for our project . Your help will be much appreciated. Thank you
ReplyDeleteHave never used assembly language or parallel ports. I would be of no use to you. Sorry.
Deletewhat are the differences of sound activated switch, microphone analog sound sensor detector module, sound digital output, and sound sensor module. I'm confused haha because the store sells different kinds of those sensors
ReplyDelete