Hi!
I have spend two days so far, combing the web, and trying many different options.
My setup;
GPS board to Uno, with nokia 5110 display.
Code is for AGV ground vehicle.
I want to use the 5110 display to show current latitude, and longitude.
I am using the NMEA library (not TinyGPS, or TinyGPS++)
MY code is not compiling; the following error keeps getting kicked out:
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
gps_module_rev4.ino: In function 'void trackGPS()':
gps_module_rev4:69: error: argument of type 'float (NMEA::)()' does not match 'float'
gps_module_rev4:70: error: argument of type 'float (NMEA::)()' does not match 'float'
here is my code:
#include <PCD8544.h>
#include <nmea.h>
#include <Servo.h>
#undef abs
#undef round
int wpt = 0;
float dest_latitude;
float dest_longitude;
float lat_f, lon_f;
static char lat_c[14];
static char lon_c[14];
NMEA gps(GPRMC); // GPS data connection to GPRMC sentence type
#define WPT_IN_RANGE_M 1
Servo esc;
Servo steering;
int gps_valid = 8;
int a=500; //adjustable delay
int steering_hi = 2127;
int esc_hi =1700;
int steering_low=985;
int esc_low =1000;
int steering_mid= 1500;
int esc_mid = 1520;
float dir; // relative direction to destination
int servo_pos = steering_mid;
static const byte LCD_WIDTH = 84;
static const byte LCD_HEIGHT = 48;
static PCD8544 lcd;
void setup() {
Serial.begin(9600);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
esc.attach(10);
steering.attach(9);
pinMode (gps_valid, OUTPUT);
digitalWrite(gps_valid, LOW);
}
void loop() {
trackWpts();
trackGPS();
lcd.setCursor(1, 0);
lcd.print("-----GPS-----");
}
void trackGPS() {
if (dest_latitude != 0 && dest_longitude != 0)
{
if (Serial.available() > 0 ) {
char c = Serial.read();
if (gps.decode(c)) {
if (gps.gprmc_status() == 'A') {
digitalWrite(gps_valid, HIGH);
lat_f=(gps.gprmc_latitude);
lon_f=(gps.gprmc_longitude);
dtostrf(lat_f,10,8,lat_c);
dtostrf(lon_f,10,8,lon_c);
lcd.setCursor(0,3);
lcd.print("Signal Fix");
lcd.setCursor(0,1);
lcd.print(lat_c);
lcd.setCursor(0,2);
lcd.print(lon_c);
// calculate relative direction to destination
dir = gps.gprmc_course_to(dest_latitude, dest_longitude) - gps.gprmc_course();
if (dir < 0)
dir += 360;
if (dir > 180)
dir -= 360;
if (dir < -75)
forward_Left();
else if (dir > 75)
forward_Right();
else
driveToTarget();
}
else
lcd.setCursor(0,3);
lcd.print("No GPS Fix");
halt();
}
}
}
else
halt();
}
void driveToTarget() {
servo_pos = map(dir, -75, 75, steering_hi, steering_low);
steering.writeMicroseconds(servo_pos);
esc.writeMicroseconds(esc_hi);
lcd.setCursor(0,4);
lcd.print("drive");
lcd.setCursor(0,5);
lcd.print(dir);
lcd.print("m to go");
}
// Movement Code
void halt()
{
lcd.setCursor(0,4);
lcd.print("halt ");
esc.writeMicroseconds(esc_mid);
steering.writeMicroseconds(steering_mid);
}
void forward()
{
lcd.setCursor(0,4);
lcd.print(" fwd ");
esc.writeMicroseconds(esc_hi);
steering.writeMicroseconds(steering_mid);
}
void forward_Left()
{
lcd.setCursor(0,4);
lcd.print("left ");
esc.writeMicroseconds(esc_hi);
steering.writeMicroseconds(steering_hi);
delay (a);
}
void forward_Right()
{
lcd.setCursor(0,4);
lcd.print("right");
esc.writeMicroseconds(esc_hi);
steering.writeMicroseconds(steering_low);
delay (a);
}
/* DEFINE GPS WPTS HERE - Create more cases as needed */
void trackWpts() {
switch(wpt) {
case 0:
dest_latitude = 40.756054;
dest_longitude = -73.986951;
break;
case 1:
dest_latitude = 37.775206;
dest_longitude = -122.419209;
break;
default:
dest_latitude = 0;
dest_longitude = 0;
break;
}
if (gps.gprmc_distance_to(dest_latitude,dest_longitude,MTR) < WPT_IN_RANGE_M)
wpt++;
}
I am forced to ask for help!!!
Sorry! LOL