Programming Basics
// Accelerate motor one from rest to 15% power over 2.5 seconds.
celerate(1,0,15,2.5);
//Run motor one at a constant speed (15% power) for 1 second.
motorSpeed(1,15);
goFor(1);
// Brake motor one.
brake(1);
//Accelerate motor two from rest to 27% power over 4 seconds.
celerate(2,0,27,4);
//Run motor two at 27% power for 2.7 seconds.
motorSpeed(2,27);
goFor(2.7);
//Decelerate motor two to 15% power in 1 second.
celerate(2,27,15,1);
//Brake motor two.
brake(2);
//Accelerate all motors to 31% power in 2 seconds.
celerate(4,0,31,2);
//Run all motors at 35% power for 1 second.
motorSpeed(4,35);
goFor(1);
//Brake motor two but keep motor one running at 35% for 3 seconds.
brake(2);
motorSpeed(1,35);
goFor(3);
//Brake all motors for 1 second.
brake(4);
goFor(1);
//Reverse direction of motor one.
reverse(1);
//Accelerate motors from start to 19% power over 2 seconds.
celerate(4,0,19,2);
//Run motor two at 35% and motor one at 19% for 2 seconds.
motorSpeed(2,35);
goFor(2);
motorSpeed(1,19);
goFor(2);
//Run both motors at 19% for 2 seconds.
motorSpeed(4,19);
goFor(2);
//Decelerate both motors to 0% over 3 seconds.
celerate(1,19,0,3);
celerate(2,19,0,3);
//Brake all motors.
brake(4);
Reflectance Sensor Test
reflectanceSensorTest();
Reflectance Sensor Functionality Test
//Run all motors at 25% power for 2 seconds.
motorSpeed(4,25);
goFor(2);
//Run all motors at 20% power over 12 feet.
motorSpeed(4,20);
goToAbsolutePosition(308);
//Reverse motors
reverse(4);
//Run all motors at 30% power for 1.5 seconds.
motorSpeed(4,30);
goFor(1.5);
//Brake all motors.
brake(4);
Arduino Data Analysis Test
//Accelerate all motors from 0 to 25% power over 3 seconds.
celerate(4,0,25,3);
//Run all motors at 25% for 1 second.
motorSpeed(4,25);
goFor(1);
//Run all motors at 20% power for 2 seconds.
motorSpeed(4,20);
goFor(2);
//Reverse all motors.
reverse(4);
//Run all motors at 25% for 2 seconds.
motorSpeed(4,25);
goFor(2);
//Brake all motors.
brake(4);
Motor Configuration
//Run all motors at 25% power for 4 seconds.
reverse(1);
motorSpeed(4,25);
goFor(4);
//Brake all motors.
brake(4);
Battery Testing
//Run all motors at 40% speed for 2.5 seconds.
motorSpeed(4,40);
goFor(2.5);
//Reverse all motors.
reverse(4);
//Run all motors at 30% speed for 4 seconds.
motorSpeed(4,30);
goFor(4);
//Reverse all motors.
reverse(4);
//Run all motors at 60% power for .3 seconds.
motorSpeed(4,60);
goFor(.3);
//Brake all motors.
brake(4);
Energy Analysis
//Reverse motor 1.
reverse(1);
//Run all motors at 30% power for 4 seconds.
motorSpeed(4,30);
goFor(4);
//Run all motors at 0% speed for 10 seconds.
motorSpeed(4,0);
goFor(10);
Performance Test 1 – Final Design
//Reverse motor 1.
reverse(1);
//Go to 250 marks from the origin position at 26% motor power. (From start to the gate)
motorSpeed(4,26);
goToAbsolutePosition(250);
//Brake all motors for 2 seconds.
brake(4);
goFor(2);
//Reverse motors and run at 30% speed for .4 seconds. (Power brake)
reverse(4);
motorSpeed(4,30);
goFor(.4);
//Reverse all motors and wait for 8.5 seconds.
reverse(4);
goFor(8.5);
//Travel 20 marks at 30% speed. (From gate to caboose)
motorSpeed(4,30);
goToRelativePosition(20);
Performance Test 1 – Test Design
//Reverse motor 1.
reverse(4);
//Go to 217 marks from the origin position at 26% motor power. (From start to the gate)
motorSpeed(4,26);
goToAbsolutePosition(217);
//Brake all motors for 2 seconds.
brake(4);
goFor(2);
//Reverse motors and run at 29% speed for .37 seconds. (Power brake)
reverse(4);
motorSpeed(4,29);
goFor(.37);
//Reverse all motors and wait for 8.5 seconds.
reverse(4);
goFor(8.5);
//Travel 20 marks at 30% speed. (From gate to caboose)
motorSpeed(4,30);
goToRelativePosition(20);
Performance Test 2 – Final Code
//Reverse all motors.
reverse(4);
//Go to 245 marks from the origin position at 24% motor power. (From start to the gate)
motorSpeed(4,24);
goToRelativePosition(245);
//Brake all motors for 2.85 seconds.
brake(4);
goFor(2.85);
//Reverse motors and run at 27.8% speed for .6 seconds. (Power brake)
reverse(4);
motorSpeed(4,27.8);
goFor(.6);
//Reverse all motors and wait for 7.5 seconds.
reverse(4);
goFor(7.5);
//Travel 25 marks at 40% speed. (From gate to caboose)
motorSpeed(4,25);
goToRelativePosition(40);
//Brake all motors for 7 seconds.
brake(4);
goFor(7);
//Reverse motors and run at 31% power for 27.5 marks.
reverse(4);
motorSpeed(4,31);
goToRelativePosition(27.5);
Performance Test 2 – Test Code
//Reverse all motors.
reverse(4);
//Go to 150 marks from the origin position at 18% motor power. (From start to the gate)
motorSpeed(4,18);
goToRelativePosition(150);
//Travel 99 marks at 29% power.
motorSpeed(4,29);
goToRelativePosition(99);
//Brake all motors for 2 seconds.
brake(4);
goFor(2);
//Reverse motors and run at 27.8% speed for .7 seconds. (Power brake)
reverse(4);
motorSpeed(4,27.8);
goFor(.7);
//Reverse all motors and wait for 8.5 seconds.
reverse(4);
goFor(8.5);
//Travel 40 marks at 25% speed. (From gate to caboose)
motorSpeed(4,25);
goToRelativePosition(40);
//Brake all motors for 5 seconds.
brake(4);
goFor(5);
//Reverse motors and run at 20% power for 36 marks.
reverse(4);
motorSpeed(4,20);
goToRelativePosition(36);
//Brake all motors for 1.8 seconds.
brake(4);
goFor(1.8);
//Run all motors at 19% power for 32 marks.
motorSpeed(4,19);
goToRelativePosition(32);
Final Performance Test Code
//Reverse all motors.
reverse(4);
//Go to 243 marks from the origin position at 25% motor power. (From start to the gate)
motorSpeed(4,25);
goToRelativePosition(243);
//Brake all motors for 2.6 seconds.
brake(4);
goFor(2.6);
//Reverse motors and run at 27.4% speed for .8 seconds. (Power brake)
reverse(4);
motorSpeed(4,27.4);
goFor(.8);
//Reverse all motors and wait for 7 seconds.
reverse(4);
goFor(7);
//Travel 46 marks at 25% speed. (From gate to caboose)
motorSpeed(4,25);
goToRelativePosition(46);
//Brake all motors for 7.2 seconds.
brake(4);
goFor(7.2);
//Reverse motors and run at 25% power for 27 marks.
reverse(4);
motorSpeed(4,25);
goToRelativePosition(27);
//Brake all motors for 7 seconds.
brake(4);
goFor(7);
//Travel 236 marks backwards at 42% power. (To gate with caboose)
motorSpeed(4,42);
goToRelativePosition(-236);
//Brake all motors for 1.8 seconds.
brake(4);
goFor(1.8);
//Reverse all motors and run at 40% power for .7 seconds. (Power break at gate)
reverse(4);
motorSpeed(4,40);
goFor(.7);
//Reverse all motors and wait for 7.5 seconds.
reverse(4);
goFor(7.5);
//Travel for 2.6 seconds at 50% speed. (From gate to start)
motorSpeed(4,50);
goFor(2.6);
//Brake motors for 5 seconds.
brake(4);
goFor(5);
//Reverse all motors and run at 45% power for 1.4 seconds. (Power break at start)
reverse(4);
motorSpeed(4,45);
goFor(1.4);