A few days ago, I was working on a project where I needed to control a stepper motor using the .NET Micro Framework on the GHI Embedded Master microprocessor. Stepper motors are a unique type of motor - the velocity is controlled by a pulse wave input. The faster the pulse frequency, the faster the motor rotates.
It turns out that most stepper motors will tend to vibrate enough that they can produce quite an audible tone at the frequency at which you are providing pulses. For instance, if you provided a pulse frequency of 440 Hz, the stepper motor would hum the pitch of concert A.
It occurred to me very quickly that I could easily program my device to use the stepper motor as a "speaker" and play a song! Programming each note one by one seemed too tedious, so I programmed a simple MIDI parser.
My project reads a MIDI file in from a USB flash drive, parses the file to gather note events, then plays the song using the PWM output on the microprocessor.
Below is a video of the player in action. Of course, the classic Mario theme was my song of choice!
Comments and suggestions are definitely welcome! I've attached my project files, so feel free to build on them.
Download Project Files