1. Analog sound sensor

소리를 감지하는 센서. 마이크로 감지된 소리를 아날로그 값으로 출력해줍니다.

Features:

  • This Analog Sound Sensor is used for sound detection, using high sensitivity cylinder Microphone sensor.
  • Small Dimension,36mm×16mm
  • Cylinder Microphone,high sensitivity
  • Fixed hole 3mm
  • With Power LED, Sensor Indicator LED

 

2. 연결방법

Pin Definition:

Pin                 Definition                 Note
Pin1 AO Sensor Analog Output
Pin2 GND Ground
Pin3 VCC Power,3.5~24V
Pin4 DO Digital Output

VCC, GND 를 아두이노의 5V, GND 에 연결. A0 핀을 아두이노의 아날로그 핀(A1, A2…)에 연결. 소리가 감지되었을 때 true/false 의 값만 필요한 경우는 A0 대신에 D0 핀을 아두이노의 디지털 핀에 연결합니다. 대신 소스에서 digitalRead() 해주면 되겠네요.

 

3. 소스코드

아날로그 신호 read

void setup()
{
  Serial.begin(9600); // open serial, set baud rate to 9600 bps
}
void loop()
{
      int val;
      val=analogRead(0);   // 아날로그 핀 번호에 맞게 수정
      Serial.println(val,DEC); //print sound value to Serial        
      delay(100);
}

 

디지털 신호 read

int inPin = 7;
void setup()
{
  Serial.begin(9600); // open serial, set baud rate to 9600 bps
  pinMode(inPin, INPUT); // 7번 핀을 input 모드로 설정
}
void loop()
{
      int val;
      val = digitalRead(inPin);   // 디지털 핀 번호에 맞게 수정
      Serial.println(val,DEC); //print sound value to Serial        
      delay(100);
}