Introduction
Sound Sensor is a component that receives sound waves and converts them into electrical signals. It detects the sound intensity in the ambient environment like a microphone does.
Components
– 1 * SunFounder Uno board
– 1 * USB data cable
– 1 * Sound Sensor module
– 1 * 3-Pin anti-reverse cable
Experimental Principle
The sensor has a capacitive electret microphone which is sensitive to sound. Sound waves cause the thin film of the electret to vibrate and then the capacitance changes, thus causing the corresponding voltage change. Since the change is extremely weak, it needs to be amplified. LM358 here is a power amplifier of 100 times gain. Connect the SIG output pin of the sound sensor to A0 of the SunFounder Uno board. Then you can see the value of sound intensity on Serial Monitor, or display the wave forms on an oscilloscope if you have connected one.
The schematic diagram of the module is as shown below:
Experimental Procedures
Step 1: Build the circuit
Step 2: Program (Please refer to the example code in LEARN -> Get Tutorials on our website)
Step 3: Compile the code
Step 4: Upload the sketch to the SunFounder Uno board
Now you can see the value of sound intensity on Serial Monitor. When the volume reaches to a certain value, the LED attached to pin 13 on the SunFounder Uno board will light up.
Code
/*********************************************** * name:Sound Sensor * function: you can see the value of sound intensity on Serial Monitor. * When the volume reaches to a certain value, the LED attached to pin 13 on the SunFounder Uno board will light up. **************************************************/ //Email:support@sunfounder.com //Website:www.sunfounder.comconst int ledPin = 13; //pin 13 built-in led const int soundPin = A0; //sound sensor attach to A0void setup() { pinMode(ledPin,OUTPUT);//set pin13 as OUTPUT Serial.begin(9600); //initialize serial }void loop() { int value = analogRead(soundPin);//read the value of A0 Serial.println(value);//print the value if(value > 600) //if the value is greater than 600 { digitalWrite(ledPin,HIGH);//turn on the led delay(200);//delay 200ms } else { digitalWrite(ledPin,LOW);//turn off the led } } |