Академический Документы
Профессиональный Документы
Культура Документы
ARDUINO
WORKSHOP
A HANDS-ON INTRODUCTION
W I T H 65 PROJECTS
JOHN BOXALL
Project #44: Creating a Simple GPS Receiver
Now lets create a simple GPS receiver. But
first, because youll usually use your GPS out-
doorsand to make things a little easier
well add an LCD module to display the data,
similar to the one shown in Figure 13-6.
The Hardware
The required hardware is minimal:
The Sketch
Enter and upload the following sketch:
void setup()
{
Serial.begin(4800);
lcd.begin(16, 2);
}
void loop()
{
byte a;
if ( Serial.available() > 0 ) // if there is data coming into the serial line
{
a = Serial.read(); // get the byte of data
if(gps.encode(a)) // if there is valid GPS data...
{
getgps(gps); // grab the data and display it on the LCD
}
}
}
Arduino Workshop
2 2013, John Boxall
But where on Earth is this? We can determine exactly where it is by
using Google Maps (http://maps.google.com/). On the website, enter the
latitude and longitude, separated by a comma and a space, into the search
field, and Google Maps will return the location. For example, using the
coordinates returned in Figure 13-7 produces a map like the one shown in
Figure 13-8.
Arduino Workshop
2013, John Boxall 3