Gps speedometer


hae ,arduino community.i working on gps speedometer project unable add warning alarm or led when vehicle attain speed eg 70 km/h.can asisst me on issue .
here code;


#include <tinygps.h>
#include <softwareserial.h>
softwareserial gps(2,3); // configure software serial port

// create instance of tinygps object
tinygps shield;

#include <liquidcrystal.h>
liquidcrystal lcd(8, 13, 9, 4, 5, 6, 7);

void setup()
{
  lcd.begin(16, 2);
  lcd.clear();
  lcd.print("tronixstuff.com");
  gps.begin(9600);
  delay(1000);
  lcd.clear(); 
}

// getgps function interpret data gps , display on serial monitor
void getgps(tinygps &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths, kmh, mph;
  shield.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);

  // print data , time
  lcd.setcursor(0,0);
  kmh=gps.f_speed_kmph();

  lcd.print(kmh, dec);
  lcd.print(" km/h      ");
/* 
  mph = kmh * 1.6;
  lcd.print(mph, dec);
  lcd.print(" mph   ");
*/
}

void loop()
{
  byte a;
  if ( gps.available() > 0 ) // if there data coming gps shield
  {
    = gps.read(); // byte of data
    if(shield.encode(a)) // if there valid gps data...
    {
      getgps(shield); // grab data , display on lcd
    }
  }
}

have getgps function return speed (kmh).  compare kmh returned getgps threshold speed. 
this give idea:

code: [select]

float getgps(tinygps &gps)  // assuming float here?
{
  int year;
  byte month, day, hour, minute, second, hundredths, kmh, mph;
  shield.crack_datetime(&year,&month,&day,&hour,&minute,&second,&hundredths);
  lcd.setcursor(0,0);
  kmh=gps.f_speed_kmph();
  lcd.print(kmh, dec);
  lcd.print(" km/h      ");
  return kph;
}

// then

if(getgps() > 70)
{
   // sound alarm, light indicator
}


Arduino Forum > Using Arduino > Project Guidance > Gps speedometer


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor