Doing a sketch to show a warning led at around 5mph, and want it to stay on until a restart / button is pressed, im a novice and trying
next step i am trying to do is if a button is pressed then re-enable loop at this point
if (kmh > 7) // // output to pin 10
digitalWrite( WARNING_LED_0, LOW );
#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
void setup()
{
pinMode( WARNING_LED_0, OUTPUT );
lcd.begin(16, 2);
lcd.clear();
lcd.print( F("gps warning) );
gpsSerial.begin(9600);
delay(2000);
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 > 7) // // output to pin 10
digitalWrite( WARNING_LED_0, LOW );
// Print time
if (fix.valid.time) {
printTime( fix.dateTime );
}
} // displayGPS
void loop()
{
while (gps.available( gpsSerial )) { // if there is data coming from the GPS shield
gps_fix fix = gps.read(); // get the complete fix structure
displayGPS( fix ); // Show pieces of the fix on the LCD
}
}