Buy from US | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES | ここでご購入を! |
The Sound Detection Sensor is a small board that combines a microphone and some processing circuitry, it has the ability to detect different sizes of sound. This sensor can be used to for a variety of uses from industrial to simple hobby or playing around.
In this lesson we will guide you through hooking up and using the Sound Detector. It will examine how the circuit works, explain some details about getting the best performance from the Sound Sensor, then present some projects that demonstrate how to use it.
The Sound Detection sensor module has a built-in capacitive electret microphone which is highly sensitive to sound. Sound waves cause the thin film of the electret to vibrate and then the capacitance changes, thus producing the corresponding changed voltage, so it can detect the sound intensity in ambient environment. Since the change is extremely weak, it needs to be amplified. We use a LM393 as the power amplifier here. You can adjust the sensitivity with by adjusting the Potentiometer. When the sound level exceeds the set point, an LED on the sensor module is illuminated and the output is sent low.
Note: This sound sensor is used to detect whether there’s sound surround or not, it cannot recognize the frequence or volum, please don’t use the module to collect sound signal.
In this example, we are going to connect the Sound Detection sensor module to the OSOYOO Basic Board digital pin to control the on-board LED, so that the LED will light up every time the sensor detects sound.
Note: The sensitivity of the Sound Detection sensor is adjustable – you may adjust it by the potentiometer.
First, please plug OSOYOO Magic I/O shield into OSOYOO Basic Board:
Overhere we use the D2 as the digital pin to connect with the sound sensor, build the circuit as below (please put the switch on sound sensor to D):
After above operations are completed, connect the OSOYOO Basic Board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Arduino IDE and choose corresponding board type and port type for you project. Then load up the following sketch onto your OSOYOO Basic Board.
int digit_sensor = 2; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int digitValue ; // value from the digit input pin void setup () { pinMode (ledPin, OUTPUT); pinMode (digit_sensor, INPUT); Serial.begin (9600); } void loop () { digitValue=digitalRead(digit_sensor); if (digitValue==LOW) { digitalWrite (ledPin, HIGH); delay(50); } else { digitalWrite (ledPin, LOW); delay(10); } }
A few seconds after the upload finishes, you can clap or knock something next to the sensor, when the volume reaches to a certain value, the LED attached to pin 13 on the Osoyoo Uno board will light up.
In this example, we will show how to use the analog pin to detect the sound. The microphone sensor will detect the sound intensity of your surroundings and will light up an LED if the sound intensity is above a certain threshold.
Overhere we use the A0 as the analog pin to connect with the sound sensor, build the circuit as below (please put the switch on sound sensor to A):
After above operations are completed, connect the OSOYOO Basic Board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Arduino IDE and choose corresponding board type and port type for you project. Then load up the following sketch onto your OSOYOO Basic Board.
const int ledPin = 13; //pin 13 built-in led const int soundPin = A0; //sound sensor attach to A0 int threshold = 600; //Set minimum threshold for LED lit void 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 > threshold) //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 } delay(1000); }
After copying and uploading this code, when the volume reaches to a certain value, the LED attached to pin 13 on the Uno board will light up. If the sound does not sense very well, try changing the threshold value or changing the sensor sensitivity by rotating the potentiometer.
You can open the Serial Monitor by going to Tools > Serial Monitor or pressing the magnifying glass-button in the OSOYOO Basic Board software window.
DownLoad Url osoyoo.com