 	
 	delay(setupDelay); // Wait for as long as required by the slowest arming module.
 }
+
+void armModules(void)
+/* Arm all the modules registered in actuators and sensors arrays by calling their
+ * arm methods and waiting for the requested duration. Wait for the longest
+ * duration necessary to arm any module and send a message over serial saying for
+ * how long Arduino  will be sleeping so that the GUI knows.
+ */
+{
+	int setupDelay(0); // By default wait for 0 seconds, i.e. arm nothing.
+	for(int i=0;i<sizeof(actuators)/sizeof(actuators[0]);i++) // Arm all actuators.
+	{
+		int delayRequested = actuators[i]->arm();
+		if (delayRequested > setupDelay) setupDelay = delayRequested;
+	}
+	for(int i=0;i<sizeof(sensors)/sizeof(sensors[0]);i++) // Arm all sensors.
+	{
+		int delayRequested = sensors[i]->arm();
+		if (delayRequested > setupDelay) setupDelay = delayRequested;
+	}
+	
+	// Send the message saying how long the delay will last.
+	outputDataBuffer += OUTPUT_START_CHAR; // Start the message.
+	outputDataBuffer += "setupDelay";
+	outputDataBuffer += DATA_DELIMITER;
+	outputDataBuffer += String(setupDelay);
+	outputDataBuffer += END_CHAR; // Terminate the message.
+	Serial.println( outputDataBuffer ); // Send the formatted message.
+	outputDataBuffer = ""; // Restart the buffer so it's clean before sending the next message.
+	
+	delay(setupDelay); // Wait for as long as required by the slowest arming module.
+}

	outputDataBuffer = ""; // Restart the buffer so it's clean before sending the next message.
}

void armModules(void)
/* Arm all the modules registered in actuators and sensors arrays by calling their
 * arm methods and waiting for the requested duration. Wait for the longest
 * duration necessary to arm any module and send a message over serial saying for
 * how long Arduino  will be sleeping so that the GUI knows.
 */
{
	int setupDelay(0); // By default wait for 0 seconds, i.e. arm nothing.
	for(int i=0;i<sizeof(actuators)/sizeof(actuators[0]);i++) // Arm all actuators.
	{
		int delayRequested = actuators[i]->arm();
		if (delayRequested > setupDelay) setupDelay = delayRequested;
	}
	for(int i=0;i<sizeof(sensors)/sizeof(sensors[0]);i++) // Arm all sensors.
	{
		int delayRequested = sensors[i]->arm();
		if (delayRequested > setupDelay) setupDelay = delayRequested;
	}
	
	// Send the message saying how long the delay will last.
	outputDataBuffer += OUTPUT_START_CHAR; // Start the message.
	outputDataBuffer += "setupDelay";

/* Prepare to listen to commands over serial and start everything up. */
{
	armModulesModule.setValue(0); // Don't arm the modules by default, wait for a command.
	armActuatorModule.setValue(-1); // Will arm the actuator that's under the index of armActuatorModule value.
	refreshRate.setValue(10); // Set default delay in milliseconds in the main loop
	forwardLED.setValue(0);
	
