极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12159|回复: 3

GPS模块为何读取不到数据?

[复制链接]
发表于 2013-11-28 13:14:56 | 显示全部楼层 |阅读模式
PIN 5 是 连接GPS 接收
PIN 4 是 连接GPS 发送

混过了 也不行读取不到



  1. #include <SoftwareSerial.h>
  2. #include <TinyGPS.h>
  3. #define RXPIN 5
  4. #define TXPIN 4
  5. TinyGPS gps;
  6. SoftwareSerial nss(RXPIN,TXPIN);

  7. long lat, lon;
  8. unsigned long fix_age, time, date, speed, course;
  9. unsigned long chars;
  10. unsigned short sentences, failed_checksum;
  11. void setup()
  12. {
  13. Serial.begin(9600);
  14. Serial.println("init ok");
  15. }

  16. void loop()
  17. {
  18.   Serial.println("Loop");
  19.   while (nss.available())   {
  20.     int c = nss.read();   
  21.   if (gps.encode(c))   
  22.     {     
  23.       
  24.       gps.stats(&chars, &sentences, &failed_checksum);
  25.     // retrieves +/- lat/long in 100000ths of a degree
  26.     gps.get_position(&lat, &lon, &fix_age);   // time in hhmmsscc, date in ddmmyy
  27.     gps.get_datetime(&date, &time, &fix_age);   // returns speed in 100ths of a knot
  28.     speed = gps.speed();   // course in 100ths of a degree
  29.     course = gps.course();
  30.     Serial.print(speed);Serial.print("  ");
  31.     Serial.print(lat);Serial.print("  ");
  32.     Serial.print(lon);Serial.println();
  33.     }  
  34.   }
  35. }




复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复

使用道具 举报

发表于 2013-11-28 18:14:50 | 显示全部楼层
那么高端 阿???
回复 支持 反对

使用道具 举报

发表于 2013-11-28 19:18:55 | 显示全部楼层
在while和if中插入print看看程序的走向。
回复 支持 反对

使用道具 举报

发表于 2014-9-30 20:09:28 | 显示全部楼层
求#include <TinyGPS.h>库文件
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-17 22:55 , Processed in 0.035419 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表