Hardware Reference
In-Depth Information
Exercises
This sketch gives surprisingly accurate results with inexpensive hardware, but
a few quick tricks might make this sketch even better. It is currently written for
the metric system, using centimeters. You could change the output to meters
when the distance value is more than 100. For people using the imperial system,
the sketch can be modii ed to print the data in inches, not in centimeters.
One good way of changing between inches and centimeters would be to
use something that the SainSmart LCD Keypad shield already has: a keypad.
Look at the documentation; the keypad is an analog device connected to
pin A0 . When the keypad is pressed, the voltage on A0 changes, and that is how
the sketch knows that a button has been pressed. Try to create something that
would change the output when one of the buttons is pressed. analogRead()
would be useful here for reading the results of keypresses.
Summary
In this chapter, you have seen not only how to connect liquid crystal displays,
but you have learned how to create special characters for your device, and how
to display data onto the screen. In the next chapter, I will show you the SD
library, how it talks to SD cards, and how it can be used to read and write data
to a card. You will see a data logging application that will allow you to write
thousands of samples to a card, and how to read them back.
 
Search WWH ::




Custom Search