Hardware Reference
In-Depth Information
The higher the sampling rate, the more accurate the result will be. The
effects of sampling speed are shown in Figure 18-2.
Slower, less accurate sampling
Faster, more accurate sampling
Figure 18-2: Sampling rates
Higher sampling rates also create more data, meaning more space is required.
Music on the Arduino
Arduinos can create musical tones because music is, put simply, repeated
frequencies. A musical A has a frequency of 220 Hz, a musical A' is double that, or
440 Hz. By knowing the frequencies of notes, it's possible to program an Arduino
to create simple musical tones. For example, the famous song “Happy Birthday”
can be written in musical tones as: “CCDCFE CCDCGF CCC1AFED BBAFGF.”
By using tone() , you can generate a musical tune to impress your friends, but
it remains a simple musical tone. The sound is clearly artii cial and does not
resemble piano tones or any other musical instrument.
CROSS REFERENCE tone() is presented in Chapter 4.
Arduino Due
The Arduino Due is a different kind of Arduino. It is based on Atmel's imple-
mentation of an ARM Cortex-M3, a powerful microcontroller and has more
processing power than most Arduinos. It is a 32-bit microcontroller, runs at
84 MHz, and has more input and output pins than most Arduinos, including
some advanced functions. Audio output on Arduinos is normally done by vary-
ing the frequency of a square wave, but the Arduino Due has two Digital to
Analog Converters (DAC) that can output a true analog signal, like the pulses
produced by tone() .
Pulse width modulation is an “all or nothing signal;” the output alternates
between a logical high and a logical low. High i delity sound is different; it
requires a signal that has multiple values between the minimum and maximum
 
Search WWH ::




Custom Search