I want to generate a sound signal by a piezo speaker and read that SAME signal by an elctret microphone and record it by Arduino Uno. So in writing the Arduino script one needs to write the signal (generate sound) and then read it (record). This means microphone is sleep when speaker is working and vice versa. Is it possible to do this task with one Arduino or not? I think my question is simple enough that does not need any further explanations. thanks
0
votes
1 Answers
1
votes
Arduino works in a main loop, you have to be good at coding, this means you have to setup some conditions that at one moment the piezo is making some noise then you record it. TBH, you should record and play the piezo at the same time otherwise you will never record what the piezo played.
void loop() {
//Output one sound to the piezo
digitalWrite(3,HIGH);
//Read and store the sound from the microphone
int sound = analogRead(A0);
}
I am worried about that the piezo might be faster than the microphone, so you will need to have to arduinos