Hardware Reference
In-Depth Information
First, set up your global
variables as usual.
Find It
/*
GPS parser
Context: Processing
This program takes in NMEA 0183 serial data and parses
out the date, time, latitude, and longitude using the GPRMC sentence.
*/
// import the serial library:
import processing.serial.*;
Serial myPort; // The serial port
float latitude = 0.0; // the latitude reading in degrees
String northSouth = "N"; // north or south?
float longitude = 0.0; // the longitude reading in degrees
String eastWest = "W"; // east or west?
float heading = 0.0; // the heading in degrees
int hrs, mins, secs; // time units
int currentDay, currentMonth, currentYear;
int satellitesInView = 0; // satellites in view
int satellitesToFix = 0; // satellites used to calculate fix
float textX = 50; // position of the text on the screen
float textY = 30;
The setup() method sets the
window size, defines the drawing
parameters, and opens the serial port.
8
void setup() {
size(400, 400); // window size
// settings for drawing:
noStroke();
smooth();
// List all the available serial ports
println(Serial.list());
// Open whatever port is the one you're using.
// for a Bluetooth device, this may be further down your
// serial port list:
String portName = Serial.list()[ 6 ];
myPort = new Serial(this, portName, 9600);
8 You will probably
need to look at the
output of Serial.list()
and change this number
to match the serial port
that corresponds to your
Bluetooth device.
// read bytes into a buffer until you get a carriage
// return (ASCII 13):
myPort.bufferUntil('\r');
}
 
Search WWH ::




Custom Search