Glossary of Arduino Basic Function Calls
celerate(m,p1,p2,t);
Accelerate or decelerate motor(s) m from power p1 to power p2 in t seconds.
Example: [1]accelerate(1,0,14,3); [2]decelerate(4,30,10,1);.
motorSpeed(m,p);
Set the speed of motor(s) m at power p.
Example: [1]motorSpeed(1,15); [2]motorSpeed(4,20);.
goFor(t);
Run motor(s) at set speed for t seconds.
Example: goFor(3);
brake(m);
Brake motor m(s). (Note: This does NOT brake the AEV, just cuts off the power of motor m)
Example: brake(4);
reverse(m);
Reverse the direction of motor(s) m.
Example: reverse(2);
goToRelativePosition(n);
Continue the command on motor(s) until the AEV reaches the desired position measured relative to CURRENT position. Positive means moving forward.
Example: [1] motorSpeed(2,30);goToRelativePosition(30); [2] motorSpeed(4,15);goToRelativePosition(-20);
goToAbsolutePosition(n);
Continue the command on motor(s) until the AEV reaches the desired position measured relative to START position.
Example: motorSpeed(4,20);goToAbsolutePosition(300);
Programming Basics
// Accelerate motor one from start to 15% power in 2.5 seconds
celerate(1,0,15,2.5);
// Run motor one at 15% power for 1 second
motorSpeed(1,15);
goFor(1);
// Brake motor one.
brake(1);
// Accelerate motor two from start to 27% power in 4 seconds
celerate(2,0,27,4);
// Run motor two at a constant 27% power for 2.7 second
motorSpeed(2,27);
goFor(2.7);
//Decelerate motor 2 to 15% power in 1 second
celerate(2,27,15,1);
//Brake motor 2
brake(2);
//Reverse the direction of motor 2
reverse(2);
//Accelerate all motors from start to 31% power in 2 seconds
celerate(4,0,31,2);
//Run all motors for 35% power for 1 second
motorSpeed(4,35);
goFor(1);
//Brake motor 2 and keep motor 1 at 35% for 3 seconds
brake(2);
motorSpeed(1,35);
goFor(3);
//Brake all motors for 1 second
brake(4);
goFor(1);
//Revserse the direction of motor 1
reverse(1);
//Accelerate motor 1 from start to 19% in 2 seconds
celerate(1,0,19,2);
//Run motor 2 at 35% power while running 1 at 19% in 2 seconds
motorSpeed(2,35);
motorSpeed(1,19);
goFor(2);
//Run all motors at 19% for 2 seconds
motorSpeed(4,19);
goFor(2);
//Decelerate all motors 50 0% in 3 seconds
celerate(4,19,0,3);
//Brake all motors
brake(4);
Testing Reflectance Sensor
// Run all motors at 25% power for 2 seconds.
motorSpeed(4,25);
goFor(2);
// Run all motors at 20% power to absolute position 12 feet.
motorSpeed(4,20);
goToAbsolutePosition(295);
//Reverse all motors.
reverse(4);
// Run all motors at 30% power for 1.5 seconds.
motorSpeed(4,30);
goFor(1.5);
// Brake all motors.
brake(4);
Design Analysis Tool
// Run all motors from start to 25% power in 3 seconds.
celerate(4,0,25,3);
// Keep all motors at 25% power for 1 second.
motorSpeed(4,25);
goFor(1);
// Keep all motors at 25% power for 1 second.
motorSpeed(4,20);
goFor(2);
// Reverse all motors.
reverse(4);
// Keep all motors at 25% power for 2 seconds.
motorSpeed(4,25);
goFor(2);
// Brake all motors.
brake(4);
Performance Test 1 Code
// Setup motors, go to the gate
motorSpeed(4,20);
goToRelativePosition(298);
// Stop motors, wait for 7 seconds
motorSpeed(4,0);
goFor(7);
// Go past the gate
motorSpeed(4,20);
goToRelativePosition(100);
brake(4);
Performance Test 2 Code
// Setup motors, go to the gate
motorSpeed(4,20);
goToRelativePosition(-298);
// Stop motors, wait for 7 seconds
motorSpeed(4,0);
goFor(7);
// Go past the gate
motorSpeed(4,20);
goToRelativePosition(-100);
//Stop at gate for 5 seconds
motorSpeed(4, 0);
GoFor(5);
//Return to gate with the caboose
motorSpeed(4,20);
goToRelativePosition(298);
// Stop motors, wait for 7 seconds
motorSpeed(4,0);
goFor(7);
// Go past the gate
motorSpeed(4,20);
goToRelativePosition(100);
//Stop all motors
brake(4);
Final Performance Test Code
//Initial motion
motorSpeed(4,70);
goToRelativePosition(-257);
motorSpeed(4,20);
goToRelativePosition(-65);
//Stop at gate (first time)
motorSpeed(4,0);
goFor(7);
//Go to end and attach caboose
motorSpeed(4,70);
goToRelativePosition(-266);
motorSpeed(4,20);
goToRelativePosition(-60);
brake(4);
//Stop at end for 5 seconds
motorSpeed(4,0);
goFor(5);
reverse(4);
//Go to gate with caboose attached
motorSpeed(4,20);
goToRelativePosition(20);
motorSpeed(4,70);
goToRelativePosition(205);
motorSpeed(4,20);
goToRelativePosition(70);
//Stop at gate
motorSpeed(4,0);
goFor(7);
//Go to end
motorSpeed(4,70);
goToRelativePosition(279);
motorSpeed(4,20);
goToRelativePosition(45);
brake(4);