i am trying to get pin 6 to trigger high within a lat/lng range at a certain speed, will the if statement i wrote work as expected? dont mind my notes they were just tests i like to keep on hand, i am quite new at this. thanks ahead of time.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup(){
Serial.begin(9600);
ss.begin(GPSBaud);
pinMode(6, OUTPUT);
}
void loop(){
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()){
Serial.print("Latitude = ");
Serial.print(gps.location.lat(), 6);
// comma 6 designates decimal place value (more places higher accuracy)
Serial.print(" Longitude = ");
Serial.println(gps.location.lng(), 6);
// Speed in miles per hour (double)
Serial.print("Speed in miles/h = ");
Serial.println(gps.speed.mph());
if (((gps.location.lat() > 58.740139) && (gps.location.lng() < 58.740150)) && ((gps.location.lng() > -37.635879) && (gps.location.lng() < -37.635899)) && (gps.speed.mph() > 5))
digitalWrite(6, HIGH);
//if (gps.location.lat() == 38.740139 && (gps.location.lng() == -77.635879 && (gps.speed.mph() >= 5 )))
delay (5000);
//if (gps.speed.mph() > 0)
//Serial.print("this is a test, ");
//delay(1000);
//if (gps.location.lat() >= 38.740)
//Serial.print("dad is great");
//delay(1000);
//if (gps.location.lng() >= -77.636)
//Serial.print(" and i love my girls ");
//delay(1000);
}
}
}