Loop not looping, or so it seems

i am needing to call a separate loop when a certain pin condition is meet, but after that loop is called, it never seems to run again, until the pin condition is changed again. using the serial monitor, i see the second loop run once, then nothing happens.

this is an on-off-auto thermostat project, the issue is when i set it to auto mode with the button, it takes pin 6 high, and then call for a second loop that contains the ds18s20 alarming code, which triggers a relay based on temp.

#include <SPI.h>
#include <Ethernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 10, 20, 30, 240 };                  // ip in lan
byte gateway[] = { 10, 20, 30, 254 };                  // internet access via router
byte subnet[] = { 255, 255, 255, 0 };                   //subnet mask
Server server(80);                                      //server port
byte sampledata=50;            //some sample data - outputs 2 (ascii = 50 DEC)
int relayPin4 = 4;  // relay pin 4
int relayState = HIGH;
int autoPin6 = 6;  // relay pin 6
int autoState = HIGH;

String readString = String(30); //string for fetching data from address
boolean MANUAL_ON1 = false; //LED status flag
boolean AUTO_ON1 = false;   

// Data wire is plugged into port 5 on the Arduino
#define ONE_WIRE_BUS 5
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer, bedroomThermometer;

// function that will be called when an alarm condition exists during DallasTemperatures::processAlarms();
void newAlarmHandler(uint8_t* deviceAddress)
{
  Serial.println("Alarm Handler Start");
  printAlarmInfo(deviceAddress);
  printTemp(deviceAddress);
  Serial.println();
  Serial.println("Alarm Handler Finish");
}

void printCurrentTemp(DeviceAddress deviceAddress)
{
  printAddress(deviceAddress);
  printTemp(deviceAddress);
  Serial.println();
}

void printAddress(DeviceAddress deviceAddress)
{
  Serial.print("Address: ");
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
  Serial.print(" ");
}

void printTemp(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC != DEVICE_DISCONNECTED)
  {
    Serial.print("Current Temp C: ");
    Serial.print(tempC);
  }
  else Serial.print("DEVICE DISCONNECTED");
  Serial.print(" ");
}

void printAlarmInfo(DeviceAddress deviceAddress)
{
  char temp;
  printAddress(deviceAddress);
  temp = sensors.getHighAlarmTemp(deviceAddress);
  Serial.print("High Alarm: ");
  Serial.print(temp, DEC);
  Serial.print("C");
  Serial.print(" Low Alarm: ");
  temp = sensors.getLowAlarmTemp(deviceAddress);
  Serial.print(temp, DEC);
  Serial.print("C");
  Serial.print(" ");
}

void setup(){
  //start Ethernet
  Ethernet.begin(mac, ip, subnet);
  
  //Set pin 4 to output
  pinMode(relayPin4, OUTPUT);
  
  //Set pin 6 to output
  pinMode(autoPin6, OUTPUT);
  
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // search for devices on the bus and assign based on an index
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");
  if (!sensors.getAddress(bedroomThermometer, 2)) Serial.println("Unable to find address for Device 2");
  
  Serial.print("Device insideThermometer ");
  printAlarmInfo(insideThermometer);
  Serial.println();

  Serial.print("Device outsideThermometer ");
  printAlarmInfo(outsideThermometer);
  Serial.println();

  Serial.print("Device bedroomThermometer ");
  printAlarmInfo(bedroomThermometer);
  Serial.println();
  
  // set alarm ranges
  Serial.println("Setting alarm temps...");
  sensors.setHighAlarmTemp(insideThermometer, 21);
  sensors.setLowAlarmTemp(insideThermometer, 0);

  Serial.print("New insideThermometer ");
  printAlarmInfo(insideThermometer);
  Serial.println();

  // attach alarm handler
  sensors.setAlarmHandler(&newAlarmHandler);
}


void loop(){
  // Create a client connection
  Client client = server.available();
  if (client) {
    while (client.connected()) {
   if (client.available()) {
    char c = client.read();
    //read char by char HTTP request
    if (readString.length() < 30)
      {
        //store characters to string
        //-----readString.append(c);
          readString.concat(c);
      }
        //output chars to serial port
        Serial.print(c);
        //if HTTP request has ended
        if (c == '\n') {
          //lets check if LED should be lighted
 //------------LED 1
         //manual mode
           if (readString.substring(6,11) == "M1=ON")
           {
             digitalWrite(relayPin4, HIGH);    // set the LED on
             digitalWrite(autoPin6, LOW);    // set the LED OFF
             MANUAL_ON1 = true;
           }
             else if (readString.substring(6,12) == "M1=OFF")
            {
             digitalWrite(relayPin4, LOW);    // set the LED OFF
             digitalWrite(autoPin6, LOW);    // set the LED OFF
             MANUAL_ON1 = false;
            }

        //auto mode
            if (readString.substring(6,11) == "A1=ON")
           {
             digitalWrite(autoPin6, HIGH);    // set the LED on
                 loopAuto();
             AUTO_ON1 = true;
           }
             else if (readString.substring(6,12) == "M1=OFF")
            {
             digitalWrite(relayPin4, LOW);    // set the LED OFF
             digitalWrite(autoPin6, LOW);    // set the LED OFF
             AUTO_ON1 = false;
            }


          // now output HTML data starting with standard header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          //set background to yellow
          client.print("<body style=background-color:white>");
          client.println("<h1>Stove control</h1>");
          client.println("<font color='black'>");
          client.println("
");

//--------LED 1 CONTROLL--------
          client.println("Select Heating Operation <form> <form method=get name=LED><input type=submit name=M1 value=ON>");
          client.println("<form method=get name=  LED><input type=submit name=M1 value=OFF  ><form>");
          client.println("<form> <form method=get name=LED><input type=submit name=A1 value=ON>");
            client.println("<font color='black' 
");
                if (MANUAL_ON1)
            {
             client.print("<font color='green' size='3'> Stove is On");
            }
            else
            {
             client.print("<font color='red' size = '3'> Stove is Off");
            }

            client.println("<font color='black' 
");
            client.println("<font color='black' 
");
                if (AUTO_ON1)
            {
             client.print("<font color='green' size='3'> Stove is running in Auto");
            }
            else
            {
             client.print("<font color='red' size = '3'> Auto Mode is Off");
            }
            client.println("<font color='black' 
");

            client.println("<font color='black' 
");

          client.println("</body></html>");
          //clearing string for next read
          readString="";
          //stopping client
          client.stop();
            }
          }
        }
      }
 delay(1000);
}

void loopAuto() {
  // ask the devices to measure the temperature
  sensors.requestTemperatures();

  // if an alarm condition exists as a result of the most recent
  // requestTemperatures() request, it exists until the next time
  // requestTemperatures() is called AND there isn't an alarm condition
  // on the device
  if (sensors.hasAlarm())
  {
    digitalWrite(relayPin4, LOW);
    Serial.println("Stove should be OFF");
  }

  // call alarm handler function defined by sensors.setAlarmHandler
  // for each device reporting an alarm
  sensors.processAlarms();

  if (!sensors.hasAlarm())
  {
     digitalWrite(relayPin4, HIGH);
     Serial.println("Stove should be On");
    // just print out the current temperature
    printCurrentTemp(insideThermometer);
    printCurrentTemp(outsideThermometer);
  }
}

your void loopAuto is a function that does not contain any loop constructs (for or while), so i will run once and then return.

So if readstring.substring(6,11) does not equal "A1=ON" the next time your void loop is executed it will not be called again.

Also in your void loop you are creating a new client every time loop is executed (every second) , if client.stop does not release the memory allocated by creating a new client you are running out of memory sooner or later (well , just sooner i guess).

Which Arduino board are you using ?

your void loopAuto is a function that does not contain any loop constructs (for or while), so i will run once and then return.

this is my first time ever programing anything like this, and i am not sure how to really use for correctly. i am thinking i want it to reread the temp every 5 min.

Also in your void loop you are creating a new client every time loop is executed (every second) , if client.stop does not release the memory allocated by creating a new client you are running out of memory sooner or later (well , just sooner i guess).

is this due to the delay(1000); that i have at the bottom of the loop?

i am using an Uno with the the ether/sd shield.