Hardware Reference
In-Depth Information
Humans have five senses. As you might have guessed, you won't be interfacing
your sense of taste with too many electronics; licking your Arduino is a poor
idea. Similarly, smell won't generally come into play. In fact, if you can smell your
electronics, something is probably burning (and you should stop what you're
doing). That just leaves the senses of touch, sight, and sound. You've already
interfaced with potentiometers and buttons that take advantage of your sense of
touch, and you've hooked up LEDs that interface with you sense of sight. Now,
what about your auditory senses? This chapter focuses on using the Arduino to
make sounds so that you can more easily gather feedback from your projects.
You can generate sound with an Arduino in a number of ways. The simplest
method is to use the tone() function, which this chapter focuses on most heavily.
However, you can also use various shields that add more complex, music-playing
capabilities to Arduino with the help of some external processing. (Shields are
add-on boards that attach to the top of your Arduino to add specific function-
ality. You won't use any in this chapter, but you'll be using assorted shields in
some of the later chapters.) If you own the Arduino Due, you can use its true
digital-to-analog converter (DAC) to produce sounds.
UnderstandingHowSpeakersWork
Before you can make sounds with your Arduino, you need to understand what
sounds are and how humans perceive them. In this first section, you learn about
how sound waves are generated, their properties, and how manipulation of
those properties can produce music, voices, and so on.
ThePropertiesofSound
Sound is transmitted through the air as a pressure wave. As an object such as
a speaker, a drum, or a bell vibrates, that object also vibrates the air around it.
As the air particles vibrate, they transfer energy to the particles around them,
vibrating these particles as well. In this fashion, a pressure wave is transferred
from the source to your eardrum, by creating a chain reaction of vibrating par-
ticles. So, why do you need to know this to understand how to make sounds
with your Arduino?
You can control two properties of these vibrating particles with your Arduino:
frequency and amplitude. The frequency represents how quickly the air particles
vibrate back and forth, and the amplitude represents the magnitude of their
vibrations. In the physical sense, higher amplitude sounds are louder, and lower
amplitude sounds are quieter. High-frequency sounds are a higher pitch (like a
soprano), and low-frequency sounds are a lower pitch (like bass). Consider the
diagram in FigureĀ 5-1, which shows sinusoidal representations of sound waves
of various amplitudes and frequencies.
 
Search WWH ::




Custom Search