Excercise 1 Code
//accelerate motor 1 from start to 15% in 2.5 s
celerate(1,0,15,2.5);
// run motor 1 at 15% for 1s
motorSpeed(1,15);
goFor(1);
//brake motor 1
brake(1);
//accelarate motor 2 from start to 27% in 4 s
celerate(2,0,27,4);
//run motor to at 27% 2.7s
motorSpeed(2,27);
goFor(2.7);
//decelerate motor 2 to 15% in 1s
celerate(2,27,15,1);
//brake motor 2
brake(2);
//reverse motor 2
reverse(2);
//acceleate all from start to 31% in 2s
celerate(1,0,31,2);
celerate(2,0,31,2);
//Run all motors at a constant speed of 35% power for 1 second.
motorSpeed(4,35);
goFor(1);
//Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds.
brake(2);
motorSpeed(1,35);
goFor(3);
//Brake all motors for 1 second
brake(4);
goFor(1);
celerate(4,35,0,4);
brake(4);
//Reverse the direction of motor one
reverse(1);
//Accelerate motor one from start to 19% power over 2 seconds.
celerate(1,0,19,2)
//Run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds
motorSpeed(4,19);
//Run both motors at a constant speed (19% power) for 2 seconds
motorSpeed(4,19);
goFor(2);
//Decelerate both motors to 0% power in 3 seconds.
// Run motor one at a constant speed (23% power) for 2.5 second.
motorSpeed(1,23);
goFor(2.5);
// Brake motor one.
brake(1);
Excercise 4 Code
celerate(4,0,25,3);
motorSpeed(4,25);
goFor(1);
motorSpeed(4,20);
goFor(2);
reverse(4);
motorSpeed(4,25);
goFor(2);
brake(4);\
Advanced R&D Code
reverse(2);
celerate(4,0,30,3);
motorSpeed(4,30);
goFor(4);
celerate(4,30,0,2);
Final Code:
reverse(2);
//Moves to the stop sign
motorSpeed(4,25);
// goFor(3.42);
goToAbsolutePosition(265);
// celerate(4,30,0,1.5);
brake(4);
//Stops a stop sign
reverse(4);
motorSpeed(4,33);
goFor(1.6);
reverse(4);
//Wait in front of the stop sign
brake(4);
goFor(7.5);
//Get it moving down the track
motorSpeed(4,25);
goToRelativePosition(80);
//Wait until it hits the caboose
brake(4);
goToRelativePosition(210);
reverse(4);
motorSpeed(4,20);
goFor(1);
//Wait w caboose for 4 seconds
brake(4);
goFor(5.5);
//accelerate the caboose up the hill
motorSpeed(4,40);
goToRelativePosition(-262);
//Stop the caboose and AEV
reverse(4);
motorSpeed(4,40);
goFor(1.5);
//Stop the caboose at the stop sign #2
brake(4);
goFor(7.5);
reverse(4);
motorSpeed(4,40);
goToRelativePosition(-130);
//Stop AEV in specific area
brake(4);
goToRelativePosition(-179);
reverse(4);
motorSpeed(4,38);
goFor(1.6);
//Final stop
brake(4);