Tras mucho tiempo sin actualizar la web os paso el código fuente, debajo del video.
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <TinyGPS.h>
#include<stdlib.h>
TinyGPS gps;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
SoftwareSerial nss(6, 7);// RX, TX
int botc = 8;
int bota = 9;
int botb = 10;
float flat, flon, falt;
float POS_LAT , POS_LON;
int year;
byte month, day, hour, minutes, second, hundredths;
unsigned long fix_age;
char buf[12];
char buf2[12];
char buf3[7];
byte modo = 0;
float fkmph = 0 ;
byte LIMvel = 50;
float distancia = 0 ;//era int
int dir = 0;
int SWgpsOK = 1;
int pinbuzzer = 13;
void setup() {
// set up the LCD's number of columns and rows:
pinMode(13, OUTPUT); // set a pin for buzzer output
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("TOMTUN V3.3");
delay(4000);
lcd.clear();
lcd.print("BUSCANDO...");
pinMode(bota, INPUT);
pinMode(botb, INPUT);
pinMode(botc, INPUT);
nss.begin (4800);
}
void loop() {
while (nss.available()) {
if (gps.encode(nss.read())) {
gps.f_get_position(&flat, &flon, &fix_age); // adquirir valores de la sentencia NMEA
gps.crack_datetime(&year, &month, &day, &hour, &minutes, &second, &hundredths, &fix_age);
fkmph = gps.f_speed_kmph();
//if (fix_age < 3000){
if (SWgpsOK == 1) // QUE NOS AVISE DE QUE YA HA TIENE LA PRIMERA POSICION GPS.
{
SWgpsOK = 0;
tone(pinbuzzer,2500,500);
lcd.clear();
}
if (digitalRead(bota) == HIGH) { // COMPROBAMOS SI HA PULSADO BOTON CAMBIAR DE MODO.
delay (200);
modo = modo + 1;
lcd.clear();
if (modo == 7 )
{ modo = 0 ;}
} // FIN DE COMPROBAR BOTON A (modo)
switch (modo) {
case 0:
dtostrf(flat, 3, 7, buf);
dtostrf(flon, 3, 7, buf2);
lcd.setCursor (0,0);
lcd.print(buf);
lcd.setCursor (0,1);
lcd.print(buf2);
break;
case 1:
lcd.setCursor (0,0);
lcd.print("SATELITES: ");
lcd.print(gps.satellites());
break;
case 2:
lcd.setCursor (0,0);
lcd.print(day);
lcd.print("/");
lcd.print(month);
lcd.print("/");
lcd.print(year);
lcd.setCursor (0,1);
lcd.print(hour + 2);
lcd.print(":");
lcd.print(minutes);
lcd.print(":");
lcd.print(second);
break;
case 3:
lcd.setCursor (0,0);
lcd.print("VELOC: ");
lcd.print(int (fkmph));
lcd.print(" Km/h");
lcd.setCursor (0,1);
lcd.print("ALTITUD: ");
falt = gps.f_altitude();
lcd.print(int (falt));
lcd.print(" m");
break;
case 4:
lcd.setCursor (0,0);
lcd.print ("AVISO V.max");
lcd.setCursor (0,1);
lcd.print (LIMvel);
if (digitalRead(botb) == HIGH || digitalRead(botc) == HIGH) {
smartdelay (200);
for ( int x = 0 ; x < 12; x++) { // durante unos segundos que se pueda cambiar el limite de LIMvel.
if ((digitalRead(botb) == HIGH) && (LIMvel > 10) ){
LIMvel = LIMvel - 10;
}
if (digitalRead(botc) == HIGH) {
LIMvel = LIMvel + 10;
}
lcd.clear();
lcd.print(LIMvel);
smartdelay (500);
if (digitalRead(bota) == HIGH){ //SALIDA SI PULSA MENU
lcd.clear();
lcd.print("NUEVO LIMITE");
lcd.setCursor (0,1);
lcd.print(LIMvel);
smartdelay (1500);
modo = 5;
lcd.clear();
break;
}
} //fin de proceso editar limite de LIMvel SALIDA POR TIEMPO
lcd.clear();
lcd.print("NUEVO LIMITE");
lcd.setCursor (0,1);
lcd.print(LIMvel);
smartdelay (1500);
modo = 5;
lcd.clear();
break;
}// fin de comprobar si ha pulsado botones para editar limite de LIMvel
break;
case 5: // fijar posicion actual
lcd.setCursor (0,0);
lcd.print("GUARDAR");
lcd.setCursor (0,1);
lcd.print("POSICION?");
if ((digitalRead(botb) == HIGH) && (digitalRead(botc) == HIGH) ){
POS_LAT = flat;
POS_LON = flon;
lcd.clear();
lcd.setCursor (0,0);
lcd.print("OK, POSICION");
lcd.setCursor (0,1);
lcd.print("GUARDADA");
smartdelay (1000);
lcd.clear();
modo = 6;
}
break;
case 6:
if (int (POS_LAT) != 0 && int (POS_LON) != 0) {
distancia = gps.distance_between(flat, flon, POS_LAT, POS_LON) ;
lcd.setCursor (0,0);
lcd.print("VEL ");
lcd.setCursor (4,0);
lcd.print(int(fkmph));
lcd.setCursor (8,0);
lcd.print("AL ");
falt = gps.f_altitude();
lcd.setCursor (11,0);
lcd.print(int (falt));
lcd.print("m");
lcd.setCursor (0,1);
lcd.print("DST ");
lcd.setCursor (5,1);
distancia = distancia / 1000;
dtostrf(distancia, 7, 3, buf3);
lcd.setCursor(4,1);
lcd.print(buf3);
lcd.print(" Km");
} else { modo = 0;}
break;
} // fin de los MODOS.
// VAMOS MAS RAPIDO DE LA CUENTA?
if ((LIMvel > 0) && ( int (fkmph) > LIMvel)) {
tone(pinbuzzer,2500,200);
smartdelay (50);
tone(pinbuzzer,2500,200);
// lcd.clear();
// lcd.setCursor (0,0);
// lcd.print("MODERE VELOCIDAD");
// lcd.setCursor (0,1);
// lcd.print("LIMITE ALCANZADO");
// smartdelay (1500);
lcd.clear();
lcd.setCursor (0,0);
lcd.print("OJO QUE VAS A");
lcd.setCursor (0,1);
lcd.print(int (fkmph));
lcd.print(" Km/h");
smartdelay (2500);
fkmph = gps.f_speed_kmph();
} // FIN DE POSIBLE PITADA POR EXCESO DE LIMvel
//}// FIN SENTENCIA CON VALORES OBSOLETOS.
} // FIN SENTENCIA DECODIFICADA
} // FIN DE PUERTO DISPONIBLE
} // FIN DE VOID LOOP
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (nss.available())
gps.encode(nss.read());
} while (millis() - start < ms);
}