Hello!!I want to interface mic and speaker to Arduino DUE.I connected mic with amplifier to analog pin of Arduino and speaker to DAC pin of Arduino, but I am not able to hear what I am saying on mic but a buzz sound hearing when i am speaking.
You need to post a schematic of how you connected the amplifier to the analogue pin and also post the code that you are running.
What sort of amplifier is it?
Most microphones only produce millivolts of output in operation. A "T-Bone" M75 produces about 2mV if you talk loudly at a distance of 200mm. Not enough for an Arduino analog input, which needs 5V to produce a "useable" value of 1023
You need to use a short length of screened cable to attach a microphone directly to the Arduino. 1 - 2 meters max. Otherwise you are bound to pick up mains hum (buzz) .
But even with this, I doubt whether you would get a large enough electrical signal from the average microphone to feed the Arduino "properly" anyway.
There's a lot of stuff already on the Arduino website you might read:
https://www.arduino.cc/en/Reference/AnalogRead
Find out using an oscilloscope or the microphone data sheet how much output it produces when you talk into it normally. Then get an audio pre-amplifier which would output say 600mV peak-peak ("Line Output" level) to the Arduino using this microphone.
How about this:
https://learn.sparkfun.com/tutorials/sound-detector-hookup-guide
- just seen it in another similar post.
but a buzz sound hearing when i am speaking
If you're only getting a buzz while you're speaking, that's probably a software problem.
and speaker to DAC pin of Arduino
The Arduino can't directly-drive a 4 or 8-Ohm speaker. Are you using an amplified speaker or an amplifier?
The 1st thing is to test the analog electronics. Connect the mic preamp's output to the speaker's input and make sure you're getting sound through (or the speaker-amplifier's input if you are using a separate amp).
If that doesn't work you can test the speakers/amp by plugging into your computer (or phone, etc.). You can test the mic preamp's output by connecting to your stereo (a "line" or "aux" input) or by plugging into your soundcard's line-input (if you have a desktop computer with a regular soundcard and line-input).
Once the analog is working you can do a rough input-test by reading the ADC and sending the results to the serial monitor. When it's quiet you should get small variations in the readings. With loud sound, you should get seemingly-random readings with a wider variation.
To test the output, you can write a little program to generate a waveform out of the DAC. A square wave would be an easy test.
Just sending the data (analog-to-digital-to-analog) through the Due without any processing is easy... Just read the 12-bit ADC and write the same value out to the 12-bit DAC, in a fast-loop.
I assume you'll be doing some DSP (otherwise there's no point) and for that you'll need a known-fixed sample rate.
For high-quality audio you'll need an analog low-pass (anti-aliasing) filter in front of the ADC.
...Remember to bias the ADC. The Arduino can't read or write negative voltages so the input (and output) have to be biased to handle AC audio. i.e. With the 12-bit ADC biased at half of 3.3V, silence should read about half of 4096.
Grumpy_Mike:
You need to post a schematic of how you connected the amplifier to the analogue pin and also post the code that you are running.
What sort of amplifier is it?
This is schematic of amplifier and mic and speaker is 2W and 8ohm which is directly connected to the pin of DAC
Grumpy_Mike:
You need to post a schematic of how you connected the amplifier to the analogue pin and also post the code that you are running.
What sort of amplifier is it?
Code is simply i am reading analog value from analog input and writing to DAC pin in a loop
A sort of schematic by numbers. I am still not clear on how the input is connected. Unless you have biased the input pin of the Arduino correctly you will only get half the wave output.
You need two 10K resistors, one pull up and the other pull down on the analogue input. Then I would reduce that 47uF cap in series with the output to a 0.1uF and remove the 4u7F altogether.
Grumpy_Mike:
A sort of schematic by numbers. I am still not clear on how the input is connected. Unless you have biased the input pin of the Arduino correctly you will only get half the wave output.You need two 10K resistors, one pull up and the other pull down on the analogue input. Then I would reduce that 47uF cap in series with the output to a 0.1uF and remove the 4u7F altogether.
Input is connected to analog pin of arduino from audio out box analog input pin is connected to 47uF capacitor
Input is connected to analog pin of arduino from audio out box analog input pin is connected to 47uF capacitor
Then that is your problem. Reply #7 told you how to fix it.
Grumpy_Mike:
Then that is your problem. Reply #7 told you how to fix it.
Will the solution will be feasible to use with 5V instead of 9V?
Will the solution will be feasible to use with 5V instead of 9V?
You must use the pull up resistors to 3V3 because this is an Arduino Due. The input must be turned down, or the gain of the amplifier reduced, so that it does not exceed 3V3 PTP voltage on the output of the amplifier.