Arduino keeps freezing when a certain piece of code is entered.

Hello.

My arduino Keeps freezing during the void setup() stage when I change this code:

if(readString.indexOf("?lighton") >0) //checks for on
          {
            digitalWrite(redLed, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          else{
            if(readString.indexOf("?lightoff") >0) //checks for off
            {
              digitalWrite(redLed, LOW);    // set pin 4 low
              Serial.println("Led Off");
            }
          }

to this:

if(readString.indexOf("?lighton") >0) //checks for on
          {
            digitalWrite(redLed, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          else{
            if(readString.indexOf("?lightoff") >0) //checks for off
            {
              digitalWrite(redLed, LOW);    // set pin 4 low
              Serial.println("Led Off");
            }
          }

          // RADIO
          if(readString.indexOf("?radioon") >0)  //checks for on
          {
            radioStat = 1;
            Serial.println("WEB: RADIO TURNED ON");
          }
          else{
            if(readString.indexOf("?radiooff") >0) //checks for off
            {
              radioStat = 0;   
              Serial.println("WEB: RADIO TURNED OFF");
            }
          }
          // END RADIO

the reason as to why I am confused is because the arduino freezes when it attempts to connect to the internet via ethernet in the void setup(), yet the code that causes the issue is at the very bottom of the void loop()…

On a rare occasion, it will work fine until I try to access the web server which will then cause the arduino to freeze completely…

Any suggestions?

Thanks

SRAM exhausted.

Any suggestions?

Serial.println(F("WEB: RADIO TURNED ON"));
and so on.

post your code, not just snippets.

Full code: http://pastebin.com/9NsXTHHZ

Yup, get those constant string out of RAM, and try not using sixteen bits when eight will do (like hours in a day, minute in an hour, pin numbers etc)

Full code:

We really do not like rubbish bin. And, there is no reason to use it. You can attach your code to your post using the Additional Options... link below this text box.

AWOL:
Yup, get those constant string out of RAM, and try not using sixteen bits when eight will do (like hours in a day, minute in an hour, pin numbers etc)

I have modified the code to do this and it appears to be working so far. I spent a good while online trying to resolve this issue before posting here, but I must have being looking in the wrong places. I appreciate everyones help!

PaulS:

Full code:

We really do not like rubbish bin. And, there is no reason to use it. You can attach your code to your post using the Additional Options... link below this text box.

The code was too big to fit into the message box here (1900 character max)

The code was too big to fit into the message box here (1900 character max)

But it wasn't too big to be attached to a post.