#include <SoftwareSerial.h> #include <TinyGPSPlus.h> TinyGPSPlus gps; SoftwareSerial mySoftwareSerialgps(2,3); float flat,flon,falt,fc,fk,fmph,fmps,fkmph; int year; byte month, day, hour, minutes, second, hundredths,nsat; unsigned long fix_age; void setup() { Serial.begin(9600); mySoftwareSerialgps.begin(9600); } void loop() { while (mySoftwareSerialgps.available()>0) { if (gps.encode(mySoftwareSerialgps.read())) { if (gps.location.isValid()) { flat= gps.location.lat(); flon =gps.location.lng(); } if (gps.altitude.isValid()) { falt= gps.altitude.meters(); } if (gps.course.isValid()) { fc= gps.course.deg(); } if (gps.satellites.isValid()) { nsat=gps.satellites.value(); } if (gps.speed.isValid()) { fk=gps.speed.knots(); fmph=gps.speed.mph(); fmps= gps.speed.mps(); fkmph =gps.speed.kmph(); } if (gps.date.isValid()) { year=gps.date.year(); month=gps.date.month(); day=gps.date.day(); } if (gps.time.isValid()) { hour=gps.time.hour(); minutes=gps.time.minute(); second=gps.time.second(); } } } Serial.println((String(hour) + String(" : ") + String(minutes))); delay(1000); }
Открыть пример: Online ArduBlock
Видеоурок: