求Arduino mega 2560与dfrobot商城的GPS(GPS接收器 Arduino兼容 5Hz...
2015-11-051.2万
AI 快速预览详细
本文讨论了如何解决Arduino Mega 2560与DFRobot GPS接收器连接后的数据输出问题。通过检查GPS数据解析和串口通信设置,可以确保正确获取经纬度信息。文章提供了详细的故障排查方法和解决方案,帮助用户解决实际问题。
|
#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 |
-
3)K~HBT$U~$U%QJY2@_HX_Q.png (17.86 KB, 下载次数: 4761)
-
-
11.64 KB, 下载次数: 5543
tinyGPS库




