Chapter 5

Making Sounds

Chapter Summary

This chapter covered the following concepts:

  • Speakers create a pressure wave that travels through the air and is perceived as sound by your ears.
  • Changing electric current induces a magnetic field that can be used to create sound from a speaker.
  • The tone() function can be used to generate sounds of arbitrary frequencies and durations.
  • the Arduino programming language supports the use of arrays for iterating through sequences of data.
  • Speaker volume can be adjusted using a potentiometer in series with a speaker.

Parts List

Useful Links


  • On page 94, when describing how speakers work, it was incorrectly stated that the induced magnetic field causes the pole piece to vibrate up and down. In actuality, the induced magnetic field causes the voice coil to vibrate up and down.

Color Wiring Diagrams


Listen to a demo of the musical tune created in the chapter:

Watch a demo of the pentatonic piano created in the chapter:


Chapter 5 Code Download

All code is licensed via the GNU GPL v3. Code is maintained and updated on GitHub. The download zip linked above always contains the most recent version of the code examples that have been pushed to the GitHub Code Repository.

Taking it Further

Use the skills that you’ve picked up in this chapter to augment previous projects that you’ve worked on or to explore more on your own. Here are a few suggestions:

  • Use a distance sensor to sound an alarm when somebody enters your room.
  • Make music that responds to environmental conditions such as light and temperature.
  • Make an audiovisual art installation that uses both lights and sounds to convey an idea or a mood.

References & Credits

  • Figure 5-2: Speaker Cross Section Credit: Public Domain from Wikipedia. (source)