Hardware Reference
In-Depth Information
Example Program
For this application, you create a digital thermometer, using an LM35, a small
thermometer that is i rst presented in Chapter 14. The schematic is almost identi-
cal, but for this application, there is a change. When the user presses a button,
the Arduino does not display the time; it says it out loud.
To do this, you have quite a bit of work to do. The Arduino cannot “speak”
directly; to say “The temperature is 22-degrees Celsius,” it requires several sound
i les. The i rst part, “The temperature is” will be one i le, and the last part, “degrees
Celsius” will also be one i le. In between, you have to record your voice or get
a friend to record theirs. Don't worry; you don't have to record every number
between zero and 100; like the previous example in Chapter 14, this application
does not go above 40. You can choose later on if you want to go higher. Also, the
English language does come to your rescue in this example; every number between
zero and 20 will have to be recorded, but after that, it is easier. For example, in the
30s, each number starts with “thirty,” followed by 1 digit. The number 37 could
therefore be a i le with the word “thirty,” and a i le with the word “seven.” This
is exactly what your GPS system does in your car; “In four-hundred meters, turn
right” is actually composed of several i les. It is up to you to create those i les or
to i nd some free audio i les on the Internet—the choice is yours.
You must decide how to proceed and with the exact wording required. For
this example, you create numerous audio i les. The i rst one, called temp.wav ,
will contain a quick phrase; “The current temperature is” or words to that effect.
Afterward, you need to create numerous i les; each number from 0 to 20 and
named as the number they contain, plus the extension .wav. For example, the
i le containing the word “18” would be “18.wav.” There is no need to record 21;
this will be done by mixing 20 and 1. Instead, record the tens: 20, 30, and 40.
For most applications, 40 should be sufi cient.
The application itself will be simple, but it is something that you can use to
create a nice project. When the user presses a button, the temperature is sampled.
One by one, i les are opened on the SD card and sent to an audio buffer. When
all the i les are read, the last i le is closed, and the system waits for the user to
press the button again.
Hardware
For this example, you will be using an Arduino Due with a shield compat-
ible with the board that has an SD slot. The Ethernet shield used in Chapter 9
would sufi ce, even if the Ethernet adapter is not used; this application needs
only the SD-card slot. The LM35's output will be connected to analog input
5, and the ground pin will be connected to the ground pin on the Arduino
Due, but the +Vs pin is different. On previous examples, it was connected to
the +5V pin because that is all that was available. However, the component's
 
Search WWH ::




Custom Search