Final Code

// GETTING US TO GATE 1st TIME

// Reverse all motors

reverse(4);

//Setall motors to 30% power and go for 2 seconds

motorSpeed(4,30);

goFor(2);

//Set all motors to 25% power and go to absolute position 410

motorSpeed(4,25);

goToAbsolutePosition(430);

 

//STOPPING US AT GATE

//Reverse all motors

reverse(4);

//Run all motors at 35% power and go for 1.5 seconds

motorSpeed(4,32);

goFor(1.5);

//Stop all motors

brake(4);

 

//ACCELERATING AFTER 1st GATE

//Reverse al motors

reverse(4);

//Run all motors at 0% power for 7 seconds

motorSpeed(4,0);

goFor(7);

//Run all motors at 30% power and go to absolute position 770

motorSpeed(4,30);

goToAbsolutePosition(740);

 

//COASTING TO THE FINISH

motorSpeed(4,0);

goFor(12);

 

//Back to Gate

reverse(4);

motorSpeed(4,39);

goToAbsolutePosition(740);

motorSpeed(4,35);

goToAbsolutePosition(617);

brake(4);

reverse(4);

motorSpeed(4,51);

goFor(2.2);

 

//Return Home

reverse(4);

motorSpeed(4,0);

goFor(7);

 

//Speed up back to home

motorSpeed(4,45);

goFor(1.5);

motorSpeed(4,35);

goToAbsolutePosition(35);

 

//STOP

reverse(4);

motorSpeed(4,51);

goFor(2);