Arduino Tone Generator/"Theremin"

So here's another quick Arduino project. It is a "theremin" of sorts, but whereas a real theremin uses antennas to control pitch and volume this on uses a potentiometer for pitch and a push button for volume. The tone is output via a piezo buzzer (as used for generating morse tones in the previous project).

Arduino "Theremin"

The voltage from the potentiometer is read via analogRead, then is mapped to a freqency to output on the buzzer. To make things sound nicer the frequencies are limited to the twelve "well tempered" notes. As the potentiometer is turned the note played changes. There's a little bit of smoothing (legato) in between note transitions too (so it sounds a bit more theremin-like).

All code for this Arduino "theremin" is available on github, as part of my Arduino Sketches project.

Here's a demo of the tone generator in action: