sound from arduino controlled by accelerometer

Hi everyone,

I am trying to learn more about using sound with arduino.

I would like to add a feature to a project of mine that will play a sound - be it a waveform or a looping sound from a file - faster or slower depending on the status of an accelerometer.

The accel part I think I can do. But I know very little and I am having some trouble finding info on playing sound with an arduino beyond a simple tone.

While my project isn’t tiny, it needs to fit in what is basically a 1 inch cylinder.

Thanks for any leads,


I'm not experienced in sound generation, but I know that a controller without DAC can produce only square waves. SPWM is possible with an 8 bit Arduino, but volume control or mixing multiple frequencies may require more computing power.

Eventually you can use multiple PWM outputs, with their own low-pass filters to produce more sinusoidal signals, and mix the resulting output signals. This will not allow for volume adjustment of the channels, though.

With a DAC it may be possible to play WAV files as well, with scalable volume. Speed adjustment is possible as well, but it will affect the frequencies at the same time.

MP3 playback will be possible as well, with a MP3 player module and enough storage space for the files.

Last not least a synthesizer module may be useful, but that's only a vague idea.

I, too, am interested in this. A question I have is that using a DAC playing back files, will it be able to play quickly enough if the refresh time needed is like 1/180th of a second?

A DAC does not play sound, it outputs a voltage depending on its digital input. To make it output a sine wave, the output must be varied continuously between the high and low peak voltage of the signal. Common update rates are IIRC 44.1kHz for WAV files, so that the output voltage changes about 3 times during output of a 15kHz sine wave period. Waves of lower frequency then are output more precisely, i.e. with more steps for every period.