Audio Output

Now we get to an exercise that is very near and dear to my heart: making sounds with the PIC. I've got three options for you here, and all use the same source code. The differences are in the volume and clarity.

These projects use a quite elementary library unit I've whipped up to create beeping sounds. It gets the job done but is pretty primitive. When I get caught up on things, I expect to write an extended unit for doing many more audio and musical things. But in the meanwhile, you should find this useful for audio annunciation. The following schematic shows the three options:

Option (a) is the simplest, and the quietest, a piezo. This is shown in the photo above. I picked up this device, surplus, from All Electronics. It gets the job done simply but really is only suitable for feedback beeps in a subdued environment. For example, beeping whenever a keyboard button is pressed.

Option (b) gives considerably more volume. Here's a photo of it in action:

Even a little speaker like this puts out a surprising amount of sound. Of course, the PIC really was never expected to drive an inductive/power device like this, so we have to limit things somewhat. In particular, with a series resistor, the joint resistance should be no less than 40 ohms. The speaker you see above is a 32 ohm affair from All Electronics, coupled with a 15 ohm resistor.

But if you really need something to cut through the din, then try the amplifier in Option (c). Connected to a bookshelf type speaker, it easily creates a room-filling volume. The LM386N-1 truly is a great chip and runs off of +5V. You'll note that I've designed in a tone and volume control, too.

So anyway, give these three options a try and start making sounds with your PIC!

Click to get the source code.
Click to get the schematic PDF.

Next Project: Electronic Drum Voice

No comments:

Post a Comment