Specific sound recognition

Hi guys!

I have a project with arduino board,a microphone LM393 and some led’s. This project is supposed to do the folowing thing blink the led’s when a specific sound is playing. Exemple: my phone rings, the programe should recognize the sound and the led’s are starting to blink.
My question is how I can transform the analog signal into digital and then the signal is going to be stored into arduino to be recognized after.

Here is my arduino code so far (the led’s blinks when a sound is playing in the background).

int DO = 2;
int DA = A0; // Pin for Analog Output - AO
int threshold = 450; //Set minimum threshold for LED lit
int sensorvalue = 0;
void setup() {
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
void loop() {
  sensorvalue = analogRead(DA);  //Read the analog value
  //Serial.print("Analog: ");
  //Serial.print(sensorvalue);  //Print the analog value
 //Serial.print("  ");
  //Serial.print("Digital: ");
 // Serial.println(digitalRead(DO));  //Print the digital value
  if (sensorvalue >= threshold) { //Compare analog value with threshold
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
  else {
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);

I will appreciate any advice, thank you!

cod.txt (801 Bytes)

That's very complicated. You could try [u]EasyVR[/u] which is designed for voice recognition, but it can be "trained" so maybe it would respond to the telephone.

Just for example, you can do limited vocabulary/limited speaker voice recognition with a "small processor" but Dragon Naturally Speaking runs on a computer, and Siri & Alexa run on powerful servers on the Internet.

And of course there are errors (false positives and false negatives).

Sound is "3-dimentional".* There is amplitude, time, and frequency.

If you record yourself saying "hello" twice, the "raw digital data" will be totally different each time. Even with something like the phone ringing you'll get differences, even if the only difference is where the digital sampling** happens in the analog waveform.

As you probably know, you are only measuring amplitude (loudness).

  • Digital audio is just amplitude & time, but the frequency information is also captured/embedded in that data and of course it can be reproduced.

** A sample represents the amplitude of the wave at one instant in time. For example, CD audio is sampled 44,100 times per second. When you play-back the DAC "connects the dots" to re-create a continuous analog waveform.

P.S. Off topic -
Back in the early 70s when I was in high school I worked for a company that rented answering machines (just one of the things they did). In those days it was illegal to hook-up anything to the phone lines unless it was supplied by the phone company.

So, the phone sat on top of the machine and the machine would pick-up the vibrations when the mechanical bell rang. Then it would mechanically lift the handset which had microphone & speaker cups attached to it. Then the tape would play & record. :smiley: :smiley: :smiley:

and then the signal is going to be stored into arduino to be recognized after.

What sort of Arduino? The Uno has only enough writable memory to hold a small fraction of a second of audio. The whole flash memory has only enough for about 3 seconds.

This sort of project is often proposed by beginners here who assume it is easy. It is not.

If I would be foolish enough to attempt it I would be using a top end Arduino with lots of memory and using correlation techniques and template matching. I would consider very carefully the number of false negatives and false positives I could tolerate before I considered it to be a success.