-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <TinyGPS++.h> | ||
#include <SoftwareSerial.h> | ||
|
||
TinyGPSPlus gps; | ||
|
||
void setup() { | ||
Serial.begin(115200); //シリアルモニターに表示させるシリアル通信 | ||
Serial1.begin(9600); //GPSと通信するシリアル通信 | ||
} | ||
|
||
void loop() { // run over and over | ||
while (Serial1.available() > 0){ //GPSと通信ができたとき | ||
char c = Serial1.read(); //UART通信で情報を読み取って変数cに代入 | ||
//Serial.print(c); | ||
gps.encode(c); //座標を数値に変換 | ||
if (gps.location.isUpdated()){ | ||
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()); //高度 | ||
} | ||
} | ||
} |