 	}
 }
 
-void server_HandleNotFound() {
+void server_HandleNotFound() { // Build error message when a request 404's
 	String message = "File Not Found\n\n";
 	message += "URI: ";
 	message += server.uri();

const int motor_BPinA = 2;
const int motor_BPinB = 3;
const int tone_Pin=13;
// NOTE: Motor max output 255

const char* esp_SSID = "CarlRobot Gamma";
const char* esp_PASS = "CarlRobot";
const bool 	esp_HOTSPOT = true; // Enable to connect to an existing network, see below
// You can have the ESP connect to your wifi network by replacing the OCSB and wireless4all found in the setup

int robot_Mode=0; //1 = linefollowing, 0 = joystick
unsigned long int loopIter=0;
ESP8266WebServer server(80); // Start webserver

void setup() {
	Serial.begin(57600); // Begin serial, higher baud rate is less stable but faster
	digitalWrite(7, HIGH); // Set HIGH output to ESP blue light
	pixels.begin();
	setLEDColour(255,0,0);
	Serial.println();

	// Legacy code, motor initializer
	sx1509.init();  // Initialize the SX1509, does Wire.begin()
    byte clockDivider = 1;
    sx1509.ledDriverInit(motor_APinA);
    sx1509.ledDriverInit(motor_APinA, clockDivider, LOGARITHMIC);
    sx1509.ledDriverInit(motor_APinB);
    sx1509.ledDriverInit(motor_APinB, clockDivider, LOGARITHMIC);
    sx1509.ledDriverInit(motor_BPinA);
    sx1509.ledDriverInit(motor_BPinA, clockDivider, LOGARITHMIC);
    sx1509.ledDriverInit(motor_BPinB);
    sx1509.ledDriverInit(motor_BPinB, clockDivider, LOGARITHMIC);

	// setup for QRE113 sensors
	sx1509.pinDir(7, OUTPUT); //servo
	sx1509.pinDir(8, OUTPUT); //ultrasonic trigger
	sx1509.pinDir(9, INPUT); //ultrasonic echo
	sx1509.pinDir(10, OUTPUT);  // Set SX1509 pin 10 as an output - enables all IR leds
	sx1509.pinDir(11, INPUT);
	sx1509.pinDir(12, INPUT);
	sx1509.pinDir(13, INPUT);
	sx1509.pinDir(14, INPUT);
	sx1509.pinDir(15, INPUT);

	if (WiFi.status() == WL_NO_SHIELD)
		while(true)
			Serial.println("WiFi shield not present");


	if (esp_HOTSPOT) {
		Serial.print("Wireless Access Point SSID: ");
		Serial.println(esp_SSID);
		WiFi.disconnect();
		WiFi.mode(WIFI_AP);
		WiFi.softAP(esp_SSID,esp_PASS);
	} else {
		esp_SSID = "OCSB";
		esp_PASS = "wireless4all";
		WiFi.mode(WIFI_STA);
		WiFi.begin(esp_SSID,esp_PASS);
		while (WiFi.status() != WL_CONNECTED) {

			ESP.restart();
		}
	}

	// Setup the network event handlers
	server.on("/",server_HandleRoot);
	server.onNotFound(server_HandleNotFound);	
	server.begin(); // Start the listeners

	// Print debug info
	Serial.print("Webserver active");
	Serial.print(" | ");
	Serial.println(WiFi.SSID());
	Serial.print("signal strength (RSSI):");
	Serial.println(WiFi.RSSI());
	Serial.println("IP Addresses: ");
	Serial.print("\tLOCAL\t");
	Serial.println(WiFi.localIP());
	Serial.print("\tSOFTAP\t");
	Serial.println(WiFi.softAPIP());

	// OTA update handling
	ArduinoOTA.begin();

	// Boot noises and colours
	tone(13, 500,250);
	delay(250);
	noTone(13);
