Final Code for Final Performance Test

Final Code

Final Code

//Part 1

 motorSpeed(4,28);

 //coast at top of hill

 goToAbsolutePosition(225);

 brake(4);

 //Air Brake before the gate

 goToAbsolutePosition(235);

 reverse(4);

  goToAbsolutePosition(240);  // sensor error 285?

 motorSpeed(4,40);

 goFor(1.5);

 //Stop at Gate

 brake(4);

 goFor(7.5);

  reverse(4);

 

 //Part 2

 

 motorSpeed(4,25);

 //go down hill

 goToAbsolutePosition(426);

 //coast

 brake(4);

 goToAbsolutePosition(476);    //Air brake halfway through hill   //Continue coasting down hill

 brake(4);

 reverse(4);

 goToAbsolutePosition(600);

 motorSpeed(4,30);

 goFor(1.5);        //Pick up Caboose

 brake(4);

 goFor(5);

 

 //Part 3

 //go back up hill

 motorSpeed(4,45);

 //coast at top of hill

 goToAbsolutePosition(430);

 brake(4);

 //Air Brake at top of hill

 goToAbsolutePosition(420);

 reverse(4);

 motorSpeed(4,25);

 goFor(1.5);

 reverse(4);

 //Stop for 7 seconds in front of sensor

 goFor(8.5);

 

 //Part 4

 //Go back down hill

 motorSpeed(4,45);

 //go down hill

 goToAbsolutePosition(255);

 //coast

 brake(4);

  reverse(4);

 goToAbsolutePosition(60);

 //Air brake halfway through hill

 //Continue coasting down hill

 

 motorSpeed(4,37);

 goFor(1.5);

 brake(4);