Skip to content

Instantly share code, notes, and snippets.

@Ryanhu1015
Created June 12, 2017 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryanhu1015/6eebd369a46a320da3db79d116ff79f2 to your computer and use it in GitHub Desktop.
Save Ryanhu1015/6eebd369a46a320da3db79d116ff79f2 to your computer and use it in GitHub Desktop.
GPS_nano_mp3
#define pinNUM 5
int location[5] = {2, 3, 4, 5, 6};
unsigned long triggerTime;
unsigned long lastTriggerTime[pinNUM] = {};
void setup()
{
for (int i = 0; i < 5; i++)
{
pinMode(location[i], OUTPUT);
digitalWrite(location[i], HIGH);
}
GPS.begin(9600);
//.
//.
//.
//there are lots of code above and it's about GPS, but not the point so skip it
}
//here also has interrupt function for GPS to grab the info
void loop()
{
triggerTime = millis();
if (GPS.newNMEAreceived())
{
GPS.parse(GPS.lastNMEA());
if (GPS.fix)
{
Serial.print("Latitude: ");
Serial.println(GPS.latitude);
Serial.print("Longitude: ");
Serial.println(GPS.longitude);
Serial.print("numebr of satellities: ");
Serial.println(GPS.satellites);
Serial.print("HDOP: ");
Serial.println(GPS.HDOP);
if (GPS.HDOP < 3)
{
if (triggerTime - lastTriggerTime[0] > 15000)// longitude and latitude of the first location will add up later
{
lastTriggerTime[0] = triggerTime;
digitalWrite(location[0], LOW);
delay(1000);
digitalWrite(location[0], HIGH);
Serial.println("song1 started!");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment