Using mkr gps shield to activate LED light

I'm currently doing a school project where we have been tasked wit programming an Arduino so that whenever the MKR GPS Shield sees that it has reached a certain coordinate threshold it will turn the light on or off (either one works) however we have come to a roadblock on how to program this behavior. After initially using the code for an Arduino LED blink and trying to hook it and the MKR GPS CODE together we realized we couldn't get the MKR to read off its values and therefore could get the two sets of code to work together. I've been searching everywhere for help on this so if anyone has an idea on how we can fix this I would be incredibly thankful.

I am confused. You mention two sets of code??? If you want help it would be best if you post your code, somebody will probably help you.

This is the current code we are trying to use: #include <Arduino_MKRGPS.h>

void setup() {

// initialize serial communications and wait for port to open:


while (!Serial) {

; // wait for serial port to connect. Needed for native USB port only


// If you are using the MKR GPS as shield, change the next line to pass

// the GPS_MODE_SHIELD parameter to the GPS.begin(...)

if (!GPS.begin()) {

Serial.println("Failed to initialize GPS!");

while (1);


void loop() {

// check if there is new GPS data available

if (GPS.available()) {

// read GPS values

float latitude   = GPS.latitude();

float longitude  = GPS.longitude();

float altitude   = GPS.altitude();

float speed      = GPS.speed();

int   satellites = GPS.satellites();

// print GPS values

Serial.print("Location: ");

Serial.print(latitude, 7);

Serial.print(", ");

Serial.println(longitude, 7);

Serial.print("Altitude: ");



Serial.print("Ground speed: ");


Serial.println(" km/h");

Serial.print("Number of satellites: ");




I've never used the MKR GPS, so this may be a totally errant response, but here goes:

  1. I don't see where you do a GPS.begin ( )
  2. If you have configured the MKR GPS as a shield, you'd have to specify GPS.begin(GPS_MODE_SHIELD) or else it will default to the I2C cable mode

I hope this might be of some small help. Good luck on your project!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.