 void storeCode(decode_results *results) {
   codeType = results->decode_type;
   int count = results->rawlen;
+  
   if (codeType == UNKNOWN) {
     Serial.println("Received unknown code, saving as raw");
+
     codeLen = results->rawlen - 1;
     // To store raw codes:
     // Drop first value (gap)
     // Convert from ticks to microseconds
     // Tweak marks shorter, and spaces longer to cancel out IR receiver distortion
     for (int i = 1; i <= codeLen; i++) {
+      /*
       if (i % 2) {
         // Mark
-        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
+        //rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
         Serial.print(" m");
-      } 
+      }
       else {
         // Space
-        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
+        //rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
         Serial.print(" s");
       }
-      Serial.print(rawCodes[i - 1], DEC);
+      //Serial.print(rawCodes[i - 1], DEC);
+      */
     }
     Serial.println("");
   }

      irsend.sendRC5(codeValue, codeLen);
    } 
    else {
      irsend.sendRC6(codeValue, codeLen);
      Serial.print("Sent RC6 ");
      Serial.println(codeValue, HEX);
    }
  } 
  else if (codeType == UNKNOWN /* i.e. raw */) {
    // Assume 38 KHz
    irsend.sendRaw(rawCodes, codeLen, 38);
    Serial.println("Sent raw");
  }
}

void ir_loop() {
  // If button pressed, send the code.
  int buttonState = digitalRead(BUTTON_PIN);
  if (lastButtonState == HIGH && buttonState == LOW) {
    Serial.println("Released");
    irrecv.enableIRIn(); // Re-enable receiver
  }

  if (buttonState) {
    Serial.println("Pressed, sending");
    digitalWrite(STATUS_PIN, HIGH);
    sendCode(lastButtonState == buttonState);
    digitalWrite(STATUS_PIN, LOW);
    delay(10); // Wait a bit between retransmissions
  } 
  else if (irrecv.decode(&results)) {
    digitalWrite(STATUS_PIN, HIGH);
    storeCode(&results);
    irrecv.resume(); // resume receiver
    digitalWrite(STATUS_PIN, LOW);
  }
  lastButtonState = buttonState;
}

void loop()
{
  //ir_loop();
  WiServer.server_task();

  delay(10);
}

    WiServer.print("<HTML><HEAD><meta http-equiv='REFRESH' content='0;url=/'></HEAD></HTML>");
    return true;
  }
 
  
  if (strcmp(URL, "/") == false) //why is this not true?
   {
      WiServer.print("<html><head><title>Led switch</title></head>");
    
      WiServer.print("<body><center>Please select the led state:<center>\n<center>");
      for (stateCounter = 0; stateCounter < 1; stateCounter++) //for each led
      {
        numAsCharBuff[0] = (char)(stateCounter + 49); //as this is displayed use 1 - 3 rather than 0 - 2
        numAsCharBuff[1] = '\0'; //strcat expects a string (array of chars) rather than a single character.
