RANDOM MUSIC BOX
Microprocessor organ and servo drum
play an endless song. By Kevin Weekly
Here’s a fairly inexpensive ($30–$40) project that
uses a microprocessor to generate a constant
stream of random but pleasant-sounding music.
A Microchip PIC16F685 generates 5 square waves
that are amplified and combined to play on a small
Photography by Sam Murphy
A lookup table in the software stores chord
progressions common in Western music. As the
music runs from chord to chord, 3 oscillators play
the chord itself, 1 plays a tonic-dominant ( 1-5) bass
pattern, and 1 plays random notes from the underlying scale as a melody. Potentiometers adjust how
much of each component (chord, bass, and melody)
is mixed into the final output.
To keep the beat, the microcontroller also generates output for driving a servomotor to strike a
drum or equivalent.
Assemble the Circuit
Download the project schematic at makezine.com/
17/diymusic_random. You can solder it onto protoboard or put it together temporarily on a solderless
breadboard. I placed and connected the components in this order: sockets, resistors, capacitors,
power wires, signal wires, potentiometers, and
finally the off-board connections to the speaker and
servo (Figure A, following page). The web page has
sketches showing each step.
Program the Microcontroller
Download the project code from makezine.com/17/
diymusic_random and use your PIC programmer
to burn the firmware onto the microcontroller.
You can either program it directly from the hex file
main.HEX or compile the program from the source