Previously Used Codes

Lab 1

Programming Basics

 

celerate(1,0,15,2.5) // Accelerate motor one from start to 15% power in 2.5 seconds.

motorSpeed(1,15); goFor(1); //Run motor one at a constant speed (15% power) for 1 second.

brake(1); //Brake motor one.

celerate(2,0,27,4); //Accelerate motor two from start to 27% power in 4 seconds.

motorSpeed(2,27); //Sets motor two to 27% power

goFor(2.7); //Run motor two at a constant speed (27% power) for 2.7 seconds.

celerate(2,27,15,1); //Decelerate motor two to 15% power in 1 second.

brake(2);  //Brake motor two.

reverse(2); //Reverse the direction of only motor 2.

celerate(4,0,31,2); //Accelerate all motors from start to 31% power in 2 seconds.

motorSpeed(4,35);

goFor(1); //Run all motors at a constant speed of 35% power for 1 second.

brake(2); //Brakes motor two

motorSpeed(1,35); //sets the first motor to 35% power

goFor(3); //Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds.

brake(4); goFor(1); //Brake all motors for 1 second.

reverse(1); //Reverse the direction of motor one.

celerate(1,0,19,2); //Accelerate motor one from start to 19% power over 2 seconds.

motorSpeed(2,35); //sets motor two to 35% power

motorSpeed(1,19); //sets motor one to 19% power

goFor(2); //Run motor two at 35% power while simultaneously running motor one at 19%

power for 2 seconds. 

motorSpeed(4,19); // sets all motors to 19% power

goFor(2); //Run both motors at a constant speed (19% power) for 2 seconds.

celerate(4,19,0,3); //Decelerate both motors to 0% power in 3 seconds.

brake(4); //Brake all motors.

 

Lab 3

External Sensor Test

 

motorSpeed(4,25); goFor(2); // Run all motors at a constant speed of 25% power for 2 seconds.

motorSpeed(4,20); // runs all motors at 20% power

goToAbsolutePosition(296); // Run all motors at a constant speed of 20% and using the goToAbsolutePosition function travel a total distance of 12 feet (from the starting point). You will actually rotate the wheel by hand (since you are on the desktop tracks) until the wheel has completed the required distance and the motors stop.

 

reverse(4); // Reverse motors.

 

motorSpeed(4,30); // runs all motors and 30% power

goFor(1.5); // Run all motors at a constant speed of 30% power for 1.5 second.

 

brake(4); // Brake all motors.

 

Lab 4

Straight Track

 

celerate(4,0,25,3); // Accelerate all motors from start to 25% in 3 seconds.

motorSpeed(4,25);

goFor(1); // Run all motors at a constant speed (25% power) for 1 second.

motorSpeed(4,20);

goFor(2); //Run all motors at 20% power for 2 seconds.

reverse(4); // Reverse all motors.

motorSpeed(4,25);

goFor(2); //Run all motors at a constant speed (25% power) for 2 second.

brake(4); //Brake all motors.