Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.