Now may you let me know what the final code without self-checking the system is that the system does not turn right ad left automatically when the power is connected or the serial monitor opened?
Take out these line
//temporary code to test the motor control functions
Serial.println("Testing motor functions. Please wait");
motorRight("testing");
delay(5000);
motorStop("testing");
delay(2000);
motorLeft("testing");
delay(5000);
motorStop("testing");
delay(2000);
Serial.println("Finished testing motor functions");
I had hoped that it would be obvious what these lines did from the comment and the messages printed.