Microphone Sound Detection Sensor Module for Arduino
Jump to navigation
Jump to search
Microphone Sound Detection Sensor Module for Arduino
http://dx.com/p/arduino-microphone-sound-detection-sensor-module-red-135533
/* Test of Noise Level Sensor SKU 135533 http://dx.com/p/arduino-microphone-sound-detection-sensor-module-red-135533 */ #define TIME 100 #define APIN A0 #define DPIN 9 int counter = 0; boolean flag = false; int sensorMaxValue = 0; int sensorAvgValue = 0; void setup() { pinMode(DPIN, INPUT); Serial.begin(9600); } void loop() { int sensorValue= analogRead(APIN); sensorAvgValue+=sensorValue; if(digitalRead(DPIN)==HIGH) flag=true; if(sensorValue>sensorMaxValue) sensorMaxValue=sensorValue; if(counter++>TIME) { Serial.print(sensorAvgValue/TIME); Serial.print(" "); Serial.print(sensorMaxValue); Serial.print(" "); if(flag) Serial.print(flag); Serial.println(); flag = false; counter = 0; sensorMaxValue = 0; sensorAvgValue = 0; } delay(1); }