본문 바로가기

IoT/Intel Edison

Grove - Sound Sensor

Grove - Sound Sensor

Grove - Sound Sensor can detect the sound strength of the environment. 
The main component of the module is a simple microphone, which is based on the LM358 amplifier and an electret microphone. 
This module's output is analog and can be easily sampled and tested by a Seeeduino.

Hardware Required
- Intel® Edison Module
- Arduino* expansion board
- Grove Base Shield v2
- Grove Sound Sensor

Circuit

Schematic



Code 
// Function: If the sound sensor senses a sound that is up to the threshold you set in the code, the LED is on for 200ms.
// Hardware: Grove - Sound Sensor, Grove - LED

/*macro definitions of the sound sensor and the LED*/
#define SOUND_SENSOR A0
#define LED 2      // the number of the LED pin

#define THRESHOLD_VALUE 400//The threshold to turn the led on 400.00*5/1024 = 1.95v
void setup() 
{
    Serial.begin(115200);
    pins_init();
}

void loop() 
{
  int sensorValue = analogRead(SOUND_SENSOR);//use A0 to read the electrical signal
  Serial.print("sensorValue ");
  Serial.println(sensorValue);
  if(sensorValue > THRESHOLD_VALUE)
  {
    turnOnLED();//if the value read from A0 is larger than 400,then light the LED
    delay(200);
  }
  turnOffLED();
}

void pins_init()
{
  pinMode(LED, OUTPUT);
  pinMode(SOUND_SENSOR, INPUT); 
}
void turnOnLED()
{
  digitalWrite(LED,HIGH);
}
void turnOffLED()
{
  digitalWrite(LED,LOW);
}

See  Also


Reference sites


'IoT > Intel Edison' 카테고리의 다른 글

Grove - LCD RGB Backlight  (0) 2015.02.09
Grove – Rotary Angle Sensor  (0) 2015.01.24
Grove - Buzzer  (0) 2015.01.24
Grove - Button and LED  (0) 2015.01.22
Blink LED in Intel® Edison for Arduino expansion board  (0) 2015.01.19