Weird Error with Adafruit GPS

My actual project is making a GPS clock that does a specific thing once a year, but I have simplified the problem down to just the GPS.

I started with the basic parsing example from Adafruit, and removed everything that is unnecessary for my project. It works fine. I am able to gather the time and date data, and print it to the monitor. The problem comes when I start to use the delay function. Suddenly everything in the sketch just stops working. It is like the Arduino is just skipping over anything with to do with GPS.

Here is the simplified version of the code

#include "string.h"
#include "ctype.h"
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

//SET GPS TO HARDWARE SERIAL
Adafruit_GPS GPS(&Serial1);
HardwareSerial mySerial = Serial1;

void setup()  
{
  Serial.begin(9600);
  Serial.println("Adafruit GPS library basic test!");

  // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); 
  GPS.sendCommand(PGCMD_ANTENNA);
}



uint32_t timer = millis();
void loop()                     // run over and over again
{
  
  //READ GPS EACH LOOP
  GPS.read();
  GPS.parse(GPS.lastNMEA());


  int Hour = GPS.hour;
  int Min = GPS.minute;
  int Day = GPS.day;
  int Month = GPS.month;
  int Year = GPS.year;

 
  // if millis() or timer wraps around, we'll just reset it
  if (timer > millis())  timer = millis();

  // approximately every 2 seconds or so, print out the current stats
  if (millis() - timer > 2000) { 
    timer = millis(); // reset the timer
    Serial.print("\nTime: ");
    Serial.print(Hour, DEC); Serial.print(':');
    Serial.println(Min, DEC); 
    Serial.print("Date: ");
    Serial.print(Day, DEC); Serial.print('/');
    Serial.print(Month, DEC); Serial.print("/20");
    Serial.println(Year, DEC);
    
  }
}

This works, but if you add "delay(100);" at the end of the sketch it just... doesn't.

A second question. If I remove the millis if/then timing stuff, it also stops working... why?

I am rather frustrated with it because this is the second time I have done this project, but the first time I used a Dexter Laboratory GPS shield. They don't make them anymore, so I resorted to the Adafruit GPS.

Any help would be greatly appreciated (I attached the full sketch. It is rather large so I didn't want to post it).

Lindsey_HP_Clock.ino (18.6 KB)

We can deal with your code a piece at a time. First, in your calculation of total days, your switch statement can be replace with

switch (Month)
{
	case 12: totaldays += 30;
	case 11: totaldays += 31;
	case 10: totaldays += 30;
	case 9:  totaldays += 31;
	case 8:  totaldays += 31;
	case 7:  totaldays += 30;
	case 6:  totaldays += 31;
	case 5:	 totaldays += 30;
	case 4:  totaldays += 31;
	case 3:  totaldays += 28;
                 totaldays += currentleap;			 
	case 2:  totaldays += 31;
	default: totaldays += day;
		 break;
}

The next bit, convert min to words, your multiple if else if tests can be replaced with

switch (Min)
{
	case 0 ... 2:
	case 59:
                <strip....>
		break;
	case 3 ... 7:
	case 53 ... 58:
                <strip....>
		break;
	case 8 ... 12:
	case 48 ... 52:
                <strip....>
		break;
	case 13 ... 17:
	case 43 ... 47:
                <strip....>
		break;
	case 18 ... 22:
	case 38 ... 42:
                <strip....>
		break;
	case 23 ... 27:
	case 33 ... 37:
                <strip....>
		break;
	case 28 ... 32:
                <strip....>
		break;
	default:
		break;
}

There are those (me) who think this makes for cleaner looking code, and we know it's all about appearances.

BTW in your original code you left out the test for 58 minutes so I made the correction (no additional charge) but you might want to check on whether the test is correct.

This works, but if you add "delay(100);" at the end of the sketch it just... doesn't.

Why would you want to? Who cares how many times loop() iterates? You are NOT being billed per iteration.

A second question. If I remove the millis if/then timing stuff, it also stops working... why?

If I take out some code (no, I'm not going to tell you which code), it stops working (no, I'm not going to tell you what it actually does or what I mean by work). Why?

Did I paraphrase you correctly?

The answer to your question is "who the f**k knows", because you have provided way too little information.