Tomtún: el gps en una lata de atún

Estoy contento, al final tantas horas de trabajo han dado su fruto. Aquí esta el resultado:




Video:




código arduino:


#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);
int ledPin = 10;
int bota = 9;
int botb = 8;
 
float flat, flon;
int year;
byte month, day, hour, minutes, second, hundredths;
unsigned long fix_age;
char buf[12];
char buf2[12];
byte modo = 0;
float fkmph = 0 ;
byte velocidad= 50;
 


void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("TOMTUN");
delay(5000);
lcd.clear();
nss.begin (9600);
lcd.print("BUSCANDO...");
pinMode(ledPin, OUTPUT);
pinMode(bota, INPUT);
pinMode(botb, INPUT);
digitalWrite(ledPin, LOW);
tone(13,3500,500);

}
void loop()
{
while (nss.available())
{

if (gps.encode(nss.read()))
{

gps.f_get_position(&flat, &flon, &fix_age);
gps.crack_datetime(&year, &month, &day, &hour, &minutes, &second, &hundredths, &fix_age);

dtostrf(flat, 3, 7, buf);
dtostrf(flon, 3, 7, buf2);

digitalWrite(ledPin, HIGH);

if (digitalRead(bota) == HIGH) { // comprobar si está activado
tone(13,3600,500);
modo = modo + 1;
delay (800);

} // FIN DE COMPROBAR BOTON A

if (digitalRead(botb) == HIGH) { // comprobar si está activado

delay (800);
lcd.clear();
lcd.setCursor (0,0);
lcd.print ("AVISO V.max");
lcd.setCursor (0,1);
lcd.print (velocidad);
delay(1500);



for ( int x = 0 ; x < 10; x++) { // durante unos segundos que se pueda cambiar el limite de velocidad.
lcd.clear();
if ((digitalRead(bota) == HIGH) && (velocidad > 0) ){

velocidad = velocidad - 10;
}
delay (500);
if ((digitalRead(botb) == HIGH) && (velocidad < 120) ){
delay (500);
velocidad = velocidad + 10;
}

lcd.print(velocidad);
delay (500);

}


} // FIN DE COMPROBAR BOTON B



switch (modo){

case 0:
lcd.clear();
lcd.setCursor (0,0);
lcd.print(buf);
lcd.setCursor (0,1);
lcd.print(buf2);
break;

case 1:
lcd.clear();
lcd.setCursor (0,0);
lcd.print("SATELITES: ");
lcd.print(gps.satellites());
break;

case 2:
lcd.clear();
lcd.setCursor (0,0);
lcd.print(day);
lcd.print("/");
lcd.print(month);
lcd.print("/");
lcd.print(year);
lcd.setCursor (0,1);
lcd.print(hour + 1);
lcd.print(":");
lcd.print(minutes);
lcd.print(":");
lcd.print(second);
break;

case 3:
lcd.clear();
lcd.setCursor (0,0);
lcd.print("VELOCIDAD:");
lcd.setCursor (0,1);
fkmph = gps.f_speed_kmph();
lcd.print(int (fkmph));
lcd.print(" Km/h");
break;

default:
modo = 0;
} // FIN DE MOSTRAR VALORES EN PANTALLA

if ((velocidad > 0) && ( int (fkmph) >= velocidad)) {
lcd.clear();
lcd.setCursor (0,0);
lcd.print("MODERE VELOCIDAD");
lcd.setCursor (0,1);
lcd.print("LIMITE ALCANZADO");
tone(13,2500,333);
tone(13,2500,333);
tone(13,2500,333);


} // FIN DE POSIBLE PITADA POR EXCESO DE VELOCIDAD


digitalWrite(ledPin, LOW);
delay (1000); // TIEMPO PARA QUE PREVALEZCAN LOS DATOS EN PANTALLA


} // FIN SENTENCIA DECODIFICADA
} // FIN DE PUERTO DISPONIBLE
} // FIN DE VOID LOOP

Comentarios

  1. muy interesante, me quisiera hacer algo parecido. Quisiera saber si tu puedes darme una pagina o decirme tu como son las conexiones en la placa.

    Saludos

    ResponderEliminar
  2. Estimadooo. Estoy buscando encontrar los datos que envía el gps pero desde una web. ¿Sabes como se podrían tomar los datos de un gps+modulo a un pc por la web? Es decir yo poder controlar los datos en mi pc y mostrarlos en la web.

    Gracias!!

    ResponderEliminar

Publicar un comentario

Entradas populares de este blog

Router Wifi con pantalla monitorizadora de URL´s solicitadas desde la red local.

TOMTUN V3.3 - Código fuente.