How do I make a long sounds detector?

Hi i'm a newbie in arduino. I need to detect long sounds (like 3000ms-5000ms) once the mic detects that duration, sound an alarm. This is for a sleep paralysis helper, it detects when i'm screaming then the alarm can make me wake up. If anyone could help it would be great :))))

Run some tutorials for the hardware selected.
If you are happy with the results of the tutorial you can merge this to your project.
Have a nice day and enjoy coding in C++.

Below to give you the idea. How you detect the sound is up to you (function soundDetector()).

void loop()
  static uint32_t startTime = 0;
  static bool soundDetected = false;

  // check sound
  if(soundDetector() == true)
    if(soundDetected == false)
      startTime = millis();
    soundDetected = true;
    soundDetected = false;

  if(soundDetected == true)
    if(millis() - startTime >= someDuration)
      // alarm here

bool soundDetector()
  // for you to do; depends on hardware
  // return true if sound is detected else false

  return true; // example return code

Study it, understand it and ask if you don't understand the idea.

Welcome to the community.

I think there are major 2 parts to this project:

  1. Mic and sensing loud sounds
    1a) Figuring out how to differentiate the Loud sound from other sounds
  2. Programming the Arduino.

I understand you are not familiar with the Arduino however know this will be the easiest part of your project. The coding is not complicated and measuring time is one of the things the Arduino does best.

I did a quick search on microphones and found a type of microphone called USB Microphone.

It may turn out to be not appropriate but the output of a USB microphone is digital and can plug right into an Android Phone.
Perhaps it is doable to have the Arduino read the digital input. This would eliminate a complex dyi interface.

Maybe someone in the forum has done this already. Keep in mind you only need volume not sound fidelity.


Perhaps a vibration sensor.

JR is right. I don't know the micro USB (it's an idea to explore), there are also these modules that allow you to adjust the sensitivity of the microphone, and that's exactly what you need, to set the detection threshold, by turning a potentiometer (and not by adjusting with difficulty a program); they can be found at the major distributors on the net, search for "sound detector" ( this one or another of the same type, they look the same).

Once you have it, you will have to make a small program that triggers your alarm, when the impulses provided by the microphone correspond to a long enough voice call. Several here will help you!
Capture d’écran_2021-12-13_10-04-42