PIC soundbyte generator

Description

This circuit was used as part of Caltech Ditch Day 2007 to play a sound clip (sequence of musical notes) upon opening a box. A single 8-pin PIC is used to generate a PWM output signal at the correct audio frequency. The note format is a subset of QBasic's PLAY command:

The last two commands are my own additions to control playback. The numerical arguments to commands are stored as a number, not in ASCII, and hence consume only a single byte. The length limit to a song is 255 bytes (must fit in a page of memory).

The PWM note tables used were generated using a PWM Calculator Other tables were generated from small C programs.

Code

The full source is here. To change the song played, modify stuff after the MySong label at the end of the code. A precompiled binary for the given hardware is here; it plays the sound in Zelda when Link opens a chest to discover an item.

Sample Songs

Here are some sample songs that you can run in QBasic format:

Photo

Photo of circuit

Schematic

Circuit schematic