Lab 01

Scenario 1

time1 = millis(); // Set the time in milliseconds
time2 = millis(); // Set the time in milliseconds
celerate(1,0,15,2.5); // Accelerate motor 1 from start to 15% power in 2.5 seconds
goFor(1); // Run last command  (motor 1 at 15% power) for 1 second
brake(1); // Brake motor 1
celerate(2,0,27,4); // Accelerate motor 2 from start to 27% power in 4 seconds
goFor(2.7); // Run last command (motor 2 at 27% power) for 2.7 seconds
celerate(2,27,15,1); // Decelerate motor 2 to 15% power for 1 second
brake(2); // Brake motor 2
reverse(2); // Reverse the direction of motor 2
celerate(4,0,31,2); // Accelerate all motors from start to 31% power in 2 seconds
motorSpeed(4,35); // Run all motors at constant speed of 35% power
goFor(1); // Run last command (all motors at 35% power) for 1 second
brake(2); // Brake motor 2
motorSpeed(1,35); Run motor 1 at constant speed of 35% power
goFor(3); //Run last command (motor 1 at 35% power) for 3 seconds
brake(4); // Brake all motors
goFor(1); // Run last command (brake all motors) for 1 second
reverse(1); // Reverse the direction of motor 1
celerate(1,0,19,2); // Accelerate motor 1 from start to 19% power for 2 seconds
if(millis()>time1)
{
motorSpeed(2,35); // Run motor 2 at 35% power
goFor(2); // Run last command (motor 2 at 35% power) for 2 seconds
celerate(2,35,0,3); // Decelerate motor 2 to 0% power in 3 seconds
}
if(millis()>time2)
{
motorSpeed(1,19); // Run motor 1 to 19% power
goFor(2); // Run last command (motor 1 at 19% power) for 2 seconds
celerate(1,19,0,3); // Decelerate motor 1 to 0% power in 3 seconds
}
brake(4); // Brake all motors

Scenario 2

reverse(4); // Reverse all motors
motorSpeed(4,25); // Run all motors to 25% power
goFor(0.5); // Run last command (all motors at 25% power) for 0.5 seconds
brake(4); // Brake all motors
goFor(0.1); // Run last command (brake all motors) for 0.1 second
celerate(4,0,25,0.5); // Run all motors from start to 25% power for 0.5 seconds
brake(4); // Brake all motors
goFor(0.1); // Run last command (brake all motors) for 0.1 second
celerate(4,0,25,0.5); // Run all motors from start to 25% power for 0.5 seconds
brake(4); // Brake all motors
goFor(0.1); // Run last command (brake all motors) for 0.1 second
motorSpeed(4,15); // Run all motors to 15% power
goFor(0.3); // Run last command (all motors at 15% power) for 0.3 seconds
brake(4); // Brake all motors
goFor(0.05); // Run last command (brake all motors) for 0.05 seconds
motorSpeed(4,40); // Run all motors to 40% power
goFor(0.3); // Run last command (all motors at 40% power) for 0.3 seconds
motorSpeed(4,25); // Run all motors to 25% power
goFor(0.5); // Run last command (all motors at 25% power) for 0.5 seconds
brake(4); // Brake all motors
goFor(0.5); // Run last command (brake all motors) for 0.5 seconds
motorSpeed(4,55); // Run all motors to 55% power
goFor(0.5); // Run last command (all motors at 55% power) for 0.5 seconds
brake(4); // Brake all motors
goFor(0.1); // Run last command (brake all motors) for 0.1 second
motorSpeed(4,55); // Run all motors to 55% power
goFor(0.5); // Run last command (all motors at 55% power) for 0.5 seconds
brake(4); // Brake all motors
goFor(0.1); // Run last command (brake all motors) for 0.1 second
motorSpeed(4,55); // Run all motors to 55% power
goFor(0.5); // Run last command (all motors at 55% power) for 0.5 seconds
brake(4); // Brake all motors
goFor(0.1); // Run last command (brake all motors) for 0.1 second
motorSpeed(4,65); // Run all motors to 65% power
goFor(0.3); // Run last command (all motors at 65% power) for 0.3 seconds
brake(4); // Brake all motors
goFor(0.05); // Run last command (brake all motors) for 0.05 seconds
motorSpeed(4,40); // Run all motors to 40% power
goFor(0.3); // Run last command (all motors at 40% power) for 0.3 seconds
motorSpeed(4,20); // Run all motors to 20% power
goFor(0.5); // Run last command (all motors at 20% power) for 0.5 seconds
motorSpeed(4,15); // Run all motors to 15% power
goFor(0.3); // Run last command (all motors at 15% power) for 0.3 seconds
brake(4); // Brake all motors
goFor(0.05); // Run last command (brake all motors) for 0.05 seconds
motorSpeed(4,40); // Run all motors to 40% power
goFor(0.3); // Run last command (all motors at 40% power) for 0.3 seconds
motorSpeed(4,25); // Run all motors to 25% power
goFor(0.5); // Run last command (all motors at 25% power) for 0.5 seconds
brake(4); // Brake all motors