How to detect multiple sound from multiple channels simultaneously?

Hellow, i'm poor grad studend majoring in entomology...
I have to make cricket sound detection system in which record whether cricket make sounds (yes or no, i don't have to record real audio).
64 cricket will be recorded simultaneously, but i have to record each cricket's song record separately .

Thus, i made prototype code and hardware to record sounds from two channel simultaneously and separately.
however, this code has problem. when the two channel receives sounds at the same time, only one of two channel record the sound...
How can i make the recording system to record simultaneously??

clap_4 is sound recording in channel 4, clap_5 is sound recording in channel 5

int clap_4;
int clap_5;

void setup(){
  Serial.begin(9600);
}

void loop() {
  int Sound_4 = digitalRead(4);
  int Sound_5 = digitalRead(5);

  if(Sound_4<=0){
    clap_4++;
    Serial.print(clap_4); Serial.println("four");  
  delay(1000);
  }
  if(Sound_5<=0){
    clap_5++;
    Serial.print(clap_5); Serial.println("five"); 
  delay(1000);
  }
}
 

You deliberately go deaf here for 1000 milliseconds.

Remove the calls to delay() and say what happens.

Next, we'll start telling you things like this must be coded without the use of delay(), and evyone will have advice for that.

You can get a head start by coming to an understanding of "blink without delay". There is example code in the IDE and of course google is your friend

Pro tip: spaces are allowed and they can help:

    Serial.print(clap_5); Serial.println(" five"); 

Along with eliminating the delays, you'll need to count not that the sound trigger is active, but that it went from inactive to active. This is called variously state change detection or edge detection and is a hole thing you can google and read about, this isn't the best but should give you ideas


This comes up all the time. Here's a recent post on a recent thread you might get something out of:

OK, the thread where I posted originally is

a7

1 Like

It would help to know the shape of the signal from the sensor. Just to be certain, can you post a link to the sound detector you are using?

What is actually doing the recording?

Can you be a little more clear as to what you REALLY want to do?

https://www.amazon.com/Stemedu-LM393-Sound-Sensor-Module/dp/B086ZHJCJB

LM393. it can detect only existence of sounds as 0 or 1.

in a room, there are several cricket cage containing a cricket making sound.
i want to know how much time the crickets make sound.
so i put a mic into each cricket cage, and detect whether they make sound.
each mic in each cage detect each cricket's sound.

I want to record the existence of cricket sound

Please answer the question.

The two of these will always prevent your program for continuing for one second, each. Replace the serial.Print() with turning a RED LED on and then next time you get a signal, turn the LED OFF!

in a room, there are several cricket cage containing a cricket making sound.
i want to know how much time the crickets make sound.
so i put a mic into each cricket cage, and detect whether they make sound.
each mic in each cage detect each cricket's sound.

Yes, that has always been clear.

The question was: what will be doing the recording?

uhm... i can't understand ur question.
Several cricket may make sounds. for example, there are 2 crickets, A and B.

  1. only A make sound
    2)only B make sound
  2. both A and B make sound
    i want to detect all three situations.

Please explain what the word "recorded" means to you in this sentence, and if some action is involved, how that action will be carried out.

AHA.
no action is involved. only mic in cage detects sound of cricket. LM-393 sound detector (mic) is used for detecting existence of sound.

This seems to be a typical xy-problem.

Ahh, so you will be collecting a bunch of data, but not doing anything with the data.

Good plan!

Thank you for kind and meaningful advise!!
I delete delay(1000), but i have another problem.
Too much counts are detected...
I want to know time length of cricket sound...

haha... i'm poor biologist...

Thank you for kind and meaningful advise!!
I delete delay(1000), but i have another problem.
Too much counts are detected...
I want to know time length of cricket sound...