Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS_test #13

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions GPS_test/GPS_test.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#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()); //高度
}
}
}
Loading