I am using Arduino's tone()
function to produce some basic tunes. However, tone()
does not have volume control.
I did post about this in the Arduino Stack Exchange web site as well. User Majenko
said that
The tone() function generates a 50% duty cycle square wave using a timer and interrupts. 50% duty cycle is basically full volume. An alternative is to do it in hardware. You can use an op-amp as buffer (or speaker driver) and a couple of resistors (or a potentiometer) as an "attenuator" before it to change the voltate of the signal going to the op-amp. You need the op-amp as a buffer because the speaker will mess with the potentiometer otherwise.
I am not so experienced in electronics and i do not understand what he means. I want to try this. Can anyone help me out with the schematic of this configuration?
There is one digital pin going to the positive end of the speaker. The negative end of the speaker goes to Arduino's GND. Can someone explain how this topology should be?