GPS模块为何读取不到数据?
PIN 5 是 连接GPS 接收PIN 4 是 连接GPS 发送
混过了 也不行读取不到
#include <SoftwareSerial.h>
#include <TinyGPS.h>
#define RXPIN 5
#define TXPIN 4
TinyGPS gps;
SoftwareSerial nss(RXPIN,TXPIN);
long lat, lon;
unsigned long fix_age, time, date, speed, course;
unsigned long chars;
unsigned short sentences, failed_checksum;
void setup()
{
Serial.begin(9600);
Serial.println("init ok");
}
void loop()
{
Serial.println("Loop");
while (nss.available()) {
int c = nss.read();
if (gps.encode(c))
{
gps.stats(&chars, &sentences, &failed_checksum);
// retrieves +/- lat/long in 100000ths of a degree
gps.get_position(&lat, &lon, &fix_age); // time in hhmmsscc, date in ddmmyy
gps.get_datetime(&date, &time, &fix_age); // returns speed in 100ths of a knot
speed = gps.speed(); // course in 100ths of a degree
course = gps.course();
Serial.print(speed);Serial.print("");
Serial.print(lat);Serial.print("");
Serial.print(lon);Serial.println();
}
}
}
那么高端 阿??? 在while和if中插入print看看程序的走向。 求#include <TinyGPS.h>库文件
页:
[1]