Hi,
I'm completely new at all this so please be kind..
For my first project I simply want my arduino to use an input microphone, and an output speaker, and hook these up - the speaker should directly output what the mic is 'hearing'.
So after some Google-Fu I bought an Arduino One with accessories (wires, breadboard etc), a MAX9814 mic, a headphone output jack etc.
So - just to test the mic and headphone connections I hooked up the Max9814 output directly to a 100uF capacitor to the headphone jack - this works, I can hear what the mic is hearing in my headphone. Yay!!
But I can't get this to work with the arduino in between.
when I connect the MAX9814 to the analog 0 input of the arduino and connect the PWM output to my 100uF capacitor / headpone output, and perform a loop analogWrite(3, analogRead(A0) >> 2);
I hear a very high tone in my headphones, and underneath that some hint of what the mic is hearing.
You'll need to increase the PWM frequency to a frequency higher than you can hear. But someone else will have to help you with that... I don't know how to do it.
PWM isn't true-analog, and the default PWM frequency of around 500Hz is very audible!
You should also put a resistor in series with the headphones because anything less than 125 Ohms will draw excess current.
If you want to do any kind of processing other than a volume change you'll also need a known sample rate.
And although you're never going to get good sound quality you'll get better quality if you run the loop faster (to sample faster) than analogRead() can run. You have to read the internal registers. (I don't know exactly how to do that either.)
What is the target of your exercise? If you want decent quality audio DSP you are barking the wrong tree. Get a board that has all audio related bells and whistles.
The target of my exercise is to have a mic live sampling audio, applying a low pass filter to the sampled signal (either in the analog domain - between mic and arduino - or digital (arduino) domain), and directly pass the signal on to a speaker.
The signal output to the speaker doesn't have to be very high resolution, it needs to be an 'okay' approximation of the mic's low frequency input.. where "okay" is a term to be defined later
I'm not aiming to build something with high audio quality - I want to build something that instantly transmits recorded "low end" to somewhere else at some sort of recognizable quality.
// set up fast sampling mode in the setup function.
ADCSRA = (ADCSRA & 0xf8) | 0x04; // set 16 times division
The problem is that you have not defined what you want to do in anything but a "hand waving" way, coupled with the lack of any knowledge about digital audio. This involves knowing things like sample rates and sample bit resolution.
Do a bit on online searching, even search this forum, because this has been asked many many times before.
Then you have enough information to start that.
What have you done and tried since you first posted your question?
Have you tried my advice in post#6 to speed up the analogue sample rate?
Have you tried what @DVDdoug told you in post#2?