Audio Output
9.0 Introduction
There are millions of Google results for “Arduino music project” and there is only space in this chapter to introduce Arduino audio techniques and some examples to get you started. Arduino wasn’t built to be a sophisticated audio synthesizer, but it can certainly produce sound through an output device such as a speaker.
This chapter shows how to create noise, play prerecorded sounds and create some simple output, and even experiment with sound synthesis.
If you want inspiration for your project, look through some of the many websites featuring music projects:
Here are just two excellent examples of what can be achieved with Arduino, some hardware, and lots of creativity:
- A laser harp
- A theremin (See Recipe 9.6 for a very simple version of this early electronic instrument, but the real thing can be made with this information.)
Sound is produced by vibrating air. A sound has a distinctive pitch if the vibration repeats regularly. The Arduino can create sound by driving a loudspeaker or Piezo device (a small ceramic transducer that produces sound when pulsed), converting electronic vibrations into speaker pulses that vibrate the air. The pitch (frequency) of the sound is determined by the time it takes to pulse the speaker in and out; the shorter the amount of time, the higher the frequency.
Tip
There are two types of Piezos you are likely to encounter. A Piezo speaker can ...
Get Arduino Cookbook, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.