6783| 3
|
[进阶] 求Arduino mega 2560与dfrobot商城的GPS(GPS接收器 Arduino兼容 5Hz... |
#include <TinyGPS.h> TinyGPS gps; unsigned long fix_age, time, date, speed, course; int DEG; int MIN1; int MIN2; /*void LAT(){ //Latitude state DEG=lat/1000000; MIN1=(lat/10000)%100; MIN2=lat%10000; Serial.println("LAT:"); Serial.print(MIN1); Serial.print("."); Serial.print(MIN2); Serial.print("' "); Serial.println(" "); } void LON(){ //Longitude state DEG=lon/1000000; MIN1=(lon/10000)%100; MIN2=(lon%10000); Serial.println("LON:"); Serial.print(DEG); Serial.print(MIN1); Serial.print("."); Serial.print(MIN2); Serial.print("' "); Serial.println(" "); } */ void setup() { Serial.begin(38400); //Set the GPS baud rate. delay(10000); } void loop() { float lat, lon; while (Serial.available()) { int c = Serial.read(); // Read the GPS data if (gps.encode(c)) // Check the GPS data { gps.f_get_position(&lat, &lon, &fix_age); // process new gps info here } } gps.f_get_position(&lat, &lon, &fix_age); // retrieves +/- lat/long in 100000ths of a degree //LAT(); //LON(); delay(1000); Serial.println(lon); } 将代码写入板子后,管脚接 TX0和RX0, 会出现四行数据(见图片),可是直接输出经纬度却不对。 根据下面的帖子,是可以在LCD上显出来,不知道为什么在我这里就不能显示出来了,求各位路过的大神指导,万分感谢。 https://wiki.dfrobot.com.cn/index.php?title=(SKU:TEL0083-A)GPS%E6%8E%A5%E6%94%B6%E5%99%A8_5Hz%E5%88%B7%E6%96%B0%E9%A2%91%E7%8E%87 |
11.64 KB, 下载次数: 3543
tinyGPS库
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed