Descripción
Un detector de sonido es básicamente un micrófono, pero esta placa ofrece mucho más que eso. La placa del detector de sonidos tiene un microcrófono electret integrado junto con el circuito integrado LM393. Se puede utilizar de diferentes maneras gracias a sus 2 salidas. El primero, el pin de salida ENVELOPE, tendremos un voltaje proporcional a la amplitud del sonido detectado y es ideal para detectar sonidos más fuerte que otros. Finalmente, la segunda salida es GATE y ofrece un nivel lógico alto cuando se detecta un sonido por encima de un cierto nivel. Puedes utilizar las tres salidas simultáneamente o solo algunas. Las que no utilices, simplemente no las conectes y listo.
Configuración de pines:
- Pin1 AO Salida Sensor Analógico
- Pin2 GND Tierra(0 volt)
- Pin3 VCC Voltaje de alimentación (3-24V)
- Pin4 DO Salida Digital
Código ejemplo:
// Henry's Bench //Arduino Sound Detection Sensor Module int soundDetectedPin = 10; // Use Pin 10 as our Input int soundDetectedVal = HIGH; // This is where we record our Sound Measurement boolean bAlarm = false; unsigned long lastSoundDetectTime; // Record the time that we measured a sound int soundAlarmTime = 500; // Number of milli seconds to keep the sound alarm high void setup () { Serial.begin(9600); pinMode (soundDetectedPin, INPUT) ; // input from the Sound Detection Module } void loop () { soundDetectedVal = digitalRead (soundDetectedPin) ; // read the sound alarm time if (soundDetectedVal == LOW) { // If we hear a sound lastSoundDetectTime = millis(); // record the time of the sound alarm // The following is so you don't scroll on the output screen if (!bAlarm) { Serial.println("LOUD, LOUD"); bAlarm = true; } } else { if ( (millis() - lastSoundDetectTime) > soundAlarmTime && bAlarm) { Serial.println("quiet"); bAlarm = false; } } }
Valoraciones
No hay valoraciones aún.