I'm building an audio project with an ATMEGA328p using an LM386 as the amplifier and the Mozzi audio library.

  • Power source is 4 AA batteries.
  • I'm using an MCP1700 voltage regulator to drop the voltage to 3.3 V for the entire circuit EXCEPT the LM386.
  • The LM386 is powered directly from the batteries at 6 V (with a 100 μF decoupling cap), bypassing the regulator, to get a better output volume.
  • Audio signal comes straight out of the Atmega pin 15 / PB1 / digital 9 through a 2.2 kΩ resistor into the LM386 (resistor is not pictured in the schematic).

The output is nice and loud and not distorted, but there is a quiet high pitched whine and a low buzzing/clicking sound in the background that sort of fluctuates; it sounds like a low pitch sawtooth wave.

What am I missing? I've read about a decoupling cap on the amp pin 7, resistors on the voltage into amp pin 6. I tried hacking these onto my PCB but didn't hear any difference in the noise.

A few schematic notes:

  • C3 is 1000 μF
  • phonesroute goes straight to a switching headphone/speaker output
  • audioout comes straight from the Atmega through a 2.2 kΩ resistor

Audio schematic

Voltage regulator schematic

  • \$\begingroup\$ What does the audio output signal of the Atmega look like? \$\endgroup\$
    – ocrdu
    Commented Feb 3, 2022 at 20:10
  • 1
    \$\begingroup\$ So what does the software on the Atmega do? Do you know what the library does? Does the sound go away if you don't use the library, don't output anything or keep the AVR in reset? Where's the rest of the schematics, there should be maybe AC coupling cap between LM386 and AVR, right? And how would a 2k2 be enough to keep the amplitude to LM386 input within specs? Have you verified with an oscilloscope that what you are doing will keep the LM386 within operating conditions? \$\endgroup\$
    – Justme
    Commented Feb 3, 2022 at 20:30
  • \$\begingroup\$ What is C2 (100nF) for? Try removing C2 and test again. \$\endgroup\$
    – rdtsc
    Commented Feb 3, 2022 at 20:52
  • \$\begingroup\$ I'd also like to point out that the 100nF cap directly on output may be a bad idea as that is against datasheet suggestions, and that the 1000uF with phones is exceptionally large, unless your hearing range goes exceptionally low which an average person would call infrasonics. Is there anything else in the circuit that would draw current at the frequency you hear? \$\endgroup\$
    – Justme
    Commented Feb 3, 2022 at 20:57
  • 1
    \$\begingroup\$ Why don't you look at the datasheet for the LM386? All circuits shown have a 10 ohms resistor in series with a 50nF capacitor as a zobel network to avoid ringing. I agree that an important series input coupling capacitor is needed to block DC on the input. \$\endgroup\$
    – Audioguru
    Commented Feb 4, 2022 at 1:55

1 Answer 1


You say the sound is not distorted but you are overloading it terribly and making it more sensitive to noise than it needs to be.

The LM386 has a gain of 20 in the configuration you are showing. Since it has a maximum output of about 4V p-p with a 6V supply the maximum input it can accept will be 200mV p-p.

Since you are using 3.3V to power the ATmega328 it will give 3.3V p-p output. You need to attenuate the output of the MCU by a factor of about 17 so as to reduce the signal to <200mV p-p.

That will still drive the output to full amplitude but will reduce the amplification of any noise by the same factor making it much less noisy.

The attenuation could be achieved with an 18k resistor from the MCU and a 1k resistor to ground. (that gives a 19:1 attenuation). Be careful that the ground of the 1k resistor is close to the LM386 rather than the MCU or there will be more opportunity to pickup nose from the ground. You will also probably get better results if the signal from the MCU is filtered by for example putting a capacitor across the 1k resistor (maybe 0.1uF) to shape the signal.

  • \$\begingroup\$ I think this is probably correct. After some experimentation I found that the undesired noise was only occurring while sound was being emitted from the atmega. And at very low output (digitally attenuated), it was very distorted sounding. I'm using simple square and triangle waves so it can be hard to tell when they are distorted. I measured the voltage coming out of the atmega and it was about 1.6v, which would be about half of 3.3v (peak-to-peak). After the 2.2k resistor, it measured a little over 1v. Seems I need to cut this voltage down as you recommended. I will try and report back \$\endgroup\$ Commented Feb 4, 2022 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.