#include #include /* This sample code demonstrates the simplified use of a TinyGPS object. It requires the use of SoftwareSerial, and assumes that you have a 9600-baud serial GPS device hooked up on pins 4(Rx) and 3(Tx). */ TinyGPSPlus gps; // Definerer en TinyGPS type kalt gps SoftwareSerial ss(4,3); // Definerer en SoftwareSerial type kalt ss static void smartdelay(unsigned long ms); void setup() { Serial.begin(9600); // Sett datahastighet til monitor ss.begin(9600); // Sett datahastighet til GPSkontrollkort } void loop() { float flat, flon; // Definer variable for lengde- og breddegrad int year; // Definer variable for år, dato og tid byte month, day, hour, minute, second, hundredths; unsigned long age; // Definer variabel for age while (ss.available() > 0) gps.encode(ss.read()); //if (gps.altitude.isUpdated()) // Serial.println(gps.altitude.meters()); Serial.print("LAT="); Serial.println(gps.location.lat(), 6); Serial.print("LONG="); Serial.println(gps.location.lng(), 6); Serial.print("ALT="); Serial.println(gps.altitude.meters()); /* Serial.println(gps.location.lat(), 6); // Latitude in degrees (double) Serial.println(gps.location.lng(), 6); // Longitude in degrees (double) Serial.print(gps.location.rawLat().negative ? "-" : "+"); Serial.println(gps.location.rawLat().deg); // Raw latitude in whole degrees Serial.println(gps.location.rawLat().billionths);// ... and billionths (u16/u32) Serial.print(gps.location.rawLng().negative ? "-" : "+"); Serial.println(gps.location.rawLng().deg); // Raw longitude in whole degrees Serial.println(gps.location.rawLng().billionths);// ... and billionths (u16/u32) Serial.println(gps.date.value()); // Raw date in DDMMYY format (u32) Serial.println(gps.date.year()); // Year (2000+) (u16) Serial.println(gps.date.month()); // Month (1-12) (u8) Serial.println(gps.date.day()); // Day (1-31) (u8) Serial.println(gps.time.value()); // Raw time in HHMMSSCC format (u32) Serial.println(gps.time.hour()); // Hour (0-23) (u8) Serial.println(gps.time.minute()); // Minute (0-59) (u8) Serial.println(gps.time.second()); // Second (0-59) (u8) Serial.println(gps.time.centisecond()); // 100ths of a second (0-99) (u8) Serial.println(gps.speed.value()); // Raw speed in 100ths of a knot (i32) Serial.println(gps.speed.knots()); // Speed in knots (double) Serial.println(gps.speed.mph()); // Speed in miles per hour (double) Serial.println(gps.speed.mps()); // Speed in meters per second (double) Serial.println(gps.speed.kmph()); // Speed in kilometers per hour (double) Serial.println(gps.course.value()); // Raw course in 100ths of a degree (i32) Serial.println(gps.course.deg()); // Course in degrees (double) -Serial.println(gps.altitude.value()); // Raw altitude in centimeters (i32) Serial.println(gps.altitude.meters()); // Altitude in meters (double) Serial.println(gps.altitude.miles()); // Altitude in miles (double) Serial.println(gps.altitude.kilometers()); // Altitude in kilometers (double) Serial.println(gps.altitude.feet()); // Altitude in feet (double) */ Serial.print("Number of satellites in use "); Serial.println(gps.satellites.value()); // Number of satellites in use (u32) /* Serial.println(gps.hdop.value()); // Horizontal Dim. of Precision (100ths-i32) */ /* gps.f_get_position(&flat, &flon, &age); // Henter breddegrader og lengdegrader Serial.print(flon,6); // Skriver ut lengdegrader i grader desimalt Serial.print(", "); // Sett inn komma som skilletegn Serial.print(flat,6); // Skriver ut breddegrader i grader desimalt Serial.print(", "); // Sett inn komma som skilletegn Serial.print(gps.f_altitude(), 2); // Skriver ut høyde over havet i meter */ Serial.println(); smartdelay(1000); } static void smartdelay(unsigned long ms) { unsigned long start = millis(); // Hent antall millisekunder siden reset av Arduino-kortet do // Testen gjøres etter loopen er kjørt { while (ss.available())gps.encode(ss.read()); } while (millis() - start < ms); // Testen gjøres før loopen er kjørt }