Chapter 3. Simple projects: input and output


This chapter covers

  • Looking at the analog world
  • Reading an analog input
  • Producing sound from a speaker
  • Building a pentatonic keyboard

In the previous chapter, we looked at the digital side of the Arduino, building a series of incremental projects that showed off Arduino features like digital inputs and outputs and interrupts. In this chapter we’re going to look at another aspect of the Arduino and how it interfaces with the world around us.

In basic terms, the world around us can be split into two parts—digital and analog—and in this chapter we’re going to investigate interacting with the analog part. We’ll once again start from a basic component, a potentiometer, which reads analog inputs into the Arduino. Then we’ll experiment by adding a sensor—a piezo transducer that can be used as an analog input or output. We’ll round up by adding four more piezo transducers and a small speaker to build a working five-key pentatonic keyboard.

These are the components required to complete this chapter:

  • An Arduino board.
  • A breadboard and a selection of jumper leads.
  • A small potentiometer. (A trimpot is ideal, as it can easily plug into a breadboard.)
  • Five zener diodes, 0.5 watt 5V1. (We used a BZX55C5V.)
  • Five uncased piezoelectric transducers (knock sensors) with wire connectors.
  • Five resistors, 1M ohm (1 mega ohm).
  • One resistor, 1k ohm.
  • A small speaker, 8 ohm.

Let’s start by learning the basics of working in analog.

3.1. Time to get analog

3.2. A piezoelectric transducer

3.3. Making a pentatonic or five-tone keyboard

3.4. Summary