I am developing an under water accoustic communication system. I got stuck in writing a code to generate digital data corresponding to the audio signal. Please give me some idea to develop the code
What sort of "sender"/"receiver" are you using? Curious about what sound frequency you're using...
http://my.fit.edu/~swood/John%20Claus%20Technical%20Paper.pdf
It's a complete example.
Please check the code which I wrote it for detecting the sound signal. I want to improve this to generate unique bit pattern for audio signal
const int microphonePin= A0; //the microphone positive terminal will connect to analog pin A0 to be read
const int ledPin=13; //the code will flash the LED connected to pin 13
int sample; //the variable that will hold the value read from the microphone each time
const int threshold= 700;//the microphone threshold sound level at which the LED will turn on
void setup() {
pinMode (ledPin, OUTPUT);//sets digital pin 13 as output
Serial.begin(9600); //sets the baud rate at 9600 so we can check the values the microphone is obtaining on the Serial Monitor
//Serial.print("sample");
//Serial.println(sample);
}
void loop(){
sample= analogRead(microphonePin); //the arduino takes continuous readings from the microphone
Serial.println(sample);
if (sample < threshold)
{
digitalWrite (ledPin, HIGH); //if the reading is greater than the threshold value, LED turns on
delay (500); //LED stays on for a half a second
//digitalWrite (ledPin, LOW); //LED turns off
}
else{ digitalWrite(ledPin, LOW); }
}
}