For a new project with Arduino I need to generate an alarm tone that needs to increase in amplitude over time if the user doesn't take action. The output would be via a small speaker.
So when the alarm condition triggers I would generate a low volume beep in the audible range, give the user some time to react, then increase the volume, wait, increase again until the user reacts. This way I don't generate a loud alarm tone from the start, which can be disturbing in a quiet environment.
Generating pulses and using a transistor or IC amplifier to drive the spaker is no trouble.
--> The issue is: how to modulate the amplitude of the speaker sound?
My limitation is that while sounding the alarm, the Arduino still needs to to other stuff, so I can't stall it in a complicated routine to generate tones for example by doing some fancy PWM that then gets filtered to deliver a signal with different amplitudes.
I could use one pin to generate the base frequency signal, and have 3 pins available to steer some external circuit to modify the amplitude, like this:
Do you guys have some ideas to share?
Tks!
ADDENDUM: This is the solution I had tried out already, but the volume levels are not repeatable from one unit to the next, so I would like to avoid adding a trimmer pot. D13 generates a square wave with the audio tone. The other outputs pipe this tone through the resistor ladder via the AND gates.