Program crashes once entering for loop

Hello, I’m working on an automation product that connects my Arduino Uno with Google Calender. I have multiple libraries that are used for this product (a timing library, temboo library, servo library). In short, the way the program is supposed to work is you schedule an event via Google Calender. The program then gets the next available event from Google Calender. If the event has the same triggername and is the same month, day, and within 3 hours of the current time then the program will wait the allotted amount of time to then perform an action. I’m having no difficulty receiving the current time, and the time of the event. My question is if the error is within the while loop I am using (to compare the date,time, and name) or if the error is with the trigger name and event name(involving strings).

Attached is my code used for this project, and a screenshot of my program crashing when entering the for loop from the serial monitor. The only thing not included is my temboo account information.

Any feedback or corrections would be helpful. Thank you for your time.

Google_Calender_Automation.ino (7.66 KB)

    while(GetNextEventChoreo.available()) {
      String name = GetNextEventChoreo.readStringUntil('\x1F');
      name.trim();
      
      String data = GetNextEventChoreo.readStringUntil('\x1E');
      data.trim();
      
      // assign the value to the appropriate String
      if (name == "BeginTime") {
       beginning = data;      //get the beginning time from google calender
      } else if (name == "Summary") {
      eventname = String(data); //get the event name from google calender
      }
      }

Why are you using a while statement here?

What type is data? Why on earth are you wrapping a String in a String?

      for (int newsec = secDifference; newsec ==0; newsec--) {     // Wait till feeding

The middle clause says to execute the for loop WHILE newsec is 0. Does that make sense to you?

      MyServo.write(92); //waits for food to drop

No, it doesn't.

Thank you for the reply Paul.

PaulS:      for (int newsec = secDifference; newsec ==0; newsec--) {     // Wait till feeding

The middle clause says to execute the for loop WHILE newsec is 0. Does that make sense to you?

Thank you for pointing this out, it makes sense that it wasn't running. I changed the code to

 for (int newsec = secDifference; newsec >0; newsec--) {

This allowed to successfully run the program once, but it crashes right after. Any idea why?

The while statement was generated with help from Temboo. Any suggestions to improve upon this?

With all those libraries and usage of Strings, you're aren't using this on a Uno, Nano or Leonardo right?

I'd be very surprised if you weren't running out of RAM.

I am actually using this on a Uno. Is there a way I can tell if memory is an issue when uploading the .ino or any suggestions to cut down on memory usage?

grizzlyberr: I am actually using this on a Uno. Is there a way I can tell if memory is an issue when uploading the .ino or any suggestions to cut down on memory usage?

If you're using 1.6.x it'll tell you the static RAM usage. Which doesn't take into account run-time. But I'd say if you're using 75% of the 2048 bytes of RAM, you're likely running out.

Wrapping all of your string constants like Serial.print() with the F() macro will drop RAM usage a bit. http://www.baldengineer.com/arduino-f-macro.html