Trying to do a little project that has an output at 6.5kmph also 14kmph but want to try to add a feature where if the speed gets to 20kmph then enables a output and only way to disable the output will be a push button input,
sorry quite new at this, this is the sketch so far
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); ;
#include <NMEAGPS.h>
#include <NeoSWSerial.h>
NeoSWSerial gpsSerial(6,7); // gps on pins 6,7
NMEAGPS gps;
const int WARNING_LED_0 = 10; // warning led on pin 10
const int WARNING_LED_1 = 13; // warning led on pin 13
void setup()
{
pinMode( WARNING_LED_0, OUTPUT );
pinMode( WARNING_LED_1, OUTPUT );
lcd.begin(16, 2);
lcd.clear();
}
void printTime( NeoGPS::time_t & time )
{
if (time.hours < 10)
lcd.print( '0' );
lcd.print( time.hours );
if (time.minutes < 10)
lcd.print( '0' );
lcd.print( time.minutes );
if (time.seconds < 10)
lcd.print( '0' );
lcd.print( time.seconds );
} // printTime
void displayGPS( gps_fix & fix )
{
int kmh = 0;
// Print speed
lcd.setCursor(0,0);
if (fix.valid.speed && (fix.spd.whole > 5)) {
kmh = (fix.spd.whole * 185) / 100;
}
lcd.print( kmh );
lcd.print( F(" km/h ") );
if (kmh > 6.5)
digitalWrite( WARNING_LED_0, LOW );
else
digitalWrite( WARNING_LED_0, HIGH );
if (kmh > 14)
digitalWrite( WARNING_LED_1, LOW );
else
digitalWrite( WARNING_LED_1, HIGH );
// Print time
if (fix.valid.time) {
printTime( fix.dateTime );
}
} // displayGPS
void loop()
{
while (gps.available( gpsSerial )) {
gps_fix fix = gps.read();
displayGPS( fix );
}
}