EasyManuals Logo

SeeedStudio Grove Series User Manual

Default Icon
51 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #36 background imageLoading...
Page #36 background image
http://www.seeedstudio.com/depot/Grove-Sound-Sensor-p-752.html?cPath=25_128
*/
#define SOUND_SENSOR 24 /* sound sensor pin */
#define LED RED_LED /* LED pin */
#define THRESHOLD_VALUE 3000 /* Depending on your LaunchPad’s ADC
resolution you may have to adjust the threshold */
#define ON HIGH /* led on */
#define OFF LOW /* led off */
#define _handle_led(x) digitalWrite(LED, x) /* handle led */
/* Global Varibles */
int sound_value = 0;
void setup() {
/* Initialize led pin */
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
}
void loop() {
/* read the sound value */
sound_value = analogRead(SOUND_SENSOR);
/* if the value is larger than threshold, turn on led */
if(sound_value > THRESHOLD_VALUE) {
_handle_led(ON);
delay(1000);
}
_handle_led(OFF);
}
RESULT
The red LED will be turned on for about 1 second when you clap your hands or snap your
fingers near the microphone.
TIPS
Analog Sound Sensor is typically used for detecting the loudness in your surroundings. Noise is
a continuous signal. For a given sample rate (fs), the bandlimit (B) for perfect reconstruction is B
≤ fs/2 according to the Nyquist Shannon sampling theorem.
批注 [17]: explain how to change this better in above
paragraph

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SeeedStudio Grove Series and is the answer not in the manual?

SeeedStudio Grove Series Specifications

General IconGeneral
BrandSeeedStudio
ModelGrove Series
CategoryMicrocontrollers
LanguageEnglish

Related product manuals