Edit 3: Code driving the Arduino:
// Pin setup int pinLeftMotorFwd = 5; int pinLeftMotorBck = 6; int pinRightMotorFwd = 10; int pinRightMotorBck = 11; // Directions for the {left, right} motors to achieve the four directions int FORWARD[] = { 1, 1 }; int BACKWARD[] = { -1, -1 }; int RIGHT[] = { -1, 1 }; int LEFT[] = { 1, -1 }; void setup() { Serial.begin(9600); pinMode(pinLeftMotorFwd, OUTPUT); pinMode(pinLeftMotorBck, OUTPUT); pinMode(pinRightMotorFwd, OUTPUT); pinMode(pinRightMotorBck, OUTPUT); } void loop() { go( FORWARD, 10 ); go( RIGHT, 3 ); go( FORWARD, 10 ); go( LEFT, 6 ); } // Move the bot in a particular direction from the array above for a given number of seconds void go ( int dir[], int dur ){ leftMotor( dir[0] ); rightMotor( dir[1] ); delay( dur * 1000 ); } // Sill both motors (OK, so stop both motors. But stop is a keyword in C) void still(){ leftMotor( 0 ); rightMotor( 0 ); } // Set the left motor to Backward (-1), Forward (1), or Stop (0) void leftMotor( int dir ){ // Pull both pins low digitalWrite(pinLeftMotorFwd, LOW ); Serial.println("pinLeftMotorFwd LOW"); digitalWrite(pinLeftMotorBck, LOW ); Serial.println("pinLeftMotorBck LOW"); // If we're going forward, pull the Fwd pin high if( dir == 1 ){ digitalWrite(pinLeftMotorFwd, HIGH); Serial.println("pinLeftMotorFwd HIGH"); } // otherwise, pull the Bck pin high else if( dir == -1 ) { digitalWrite(pinLeftMotorBck, HIGH); Serial.println("pinLeftMotorBck HIGH"); } } // Set the right motor to Backward (-1), Forward (1), or Stop (0) void rightMotor( int dir ){ // Pull both pins low digitalWrite(pinRightMotorFwd, LOW ); Serial.println("pinRightMotorFwd LOW"); digitalWrite(pinRightMotorBck, LOW ); Serial.println("pinRightMotorBck LOW"); // If we're going forward, pull the Fwd pin high if( dir == 1 ){ digitalWrite(pinRightMotorFwd, HIGH); Serial.println("pinRightMotorFwd HIGH"); } // otherwise, pull the Bck pin high else if( dir == -1 ) { digitalWrite(pinRightMotorBck, HIGH); Serial.println("pinRightMotorBck HIGH"); } } 