Arduino sound detect sensor ON/OFF LED Tutorial - zonemaker.com




Sound Detection Sensor Module
The Sound sensor module is a simple microphone. Based on the power amplifier LM393 and the electret microphone, it can be used to detect whether there is any sound that beyond the threshold. The threshold can be adjusted by the on-board potentiometer.
    Adjust the on-board potentiometer to adjust the sensitivity. The module output HIHG/LOW when the voice is Lower/higher than the threshold set by the potentiometer.
Please note that this sensor can only outputs if there is sound that beyond the threshold, but not the loudness and frequency


Schematic diagram

Hardward

- Arduino board
- Sound Sensor Module  🛒→  https://goo.gl/ufVtKy
- LED 
- Resistor 220 Ω
- Breadboard
- Jumper wires

Arduino Sketch

int soundSensor = 2;
int LED = 7;
bool isLEDOn = false;
void setup() 
{
  Serial.begin(9600);
  pinMode (soundSensor, INPUT);
  pinMode (LED, OUTPUT);
  digitalWrite( LED,LOW);
}
void loop()
{
  int statusSensor = digitalRead (soundSensor);
  if (statusSensor == 1)
  {
       Serial.println("ON");
       if( isLEDOn == false){
          isLEDOn = true;
          digitalWrite(LED, HIGH);
       }else{
          isLEDOn = false;
          digitalWrite(LED, LOW);
       }   
  }
   else
  {
    Serial.println("zzz"); 
  }  
}

ความคิดเห็น