Arduino Codes

Programming Basics

1. Accelerate motor one from start to 15% power in 2.5 seconds.

celerate(1,0,15,2.5);

2. Run motor one at a constant speed (15% power) for 1 second.

motorSpeed(1,15);

goFor(1);

3. Brake motor one.

brake(1);

4. Accelerate motor two from start to 27% power in 4 seconds.

celerate(2,0,27,4);

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

motorSpeed(2,27);

goFor(2.7);

6. Decelerate motor two to 15% power in 1 second.

celerate(2,27,15,1);

7. Brake motor two.

brake(2);

8. Reverse the direction of only motor 2.

reverse(2);

9. Accelerate all motors from start to 31% power in 2 seconds.

celerate(4,0,31,2);

10.Run all motors at a constant speed of 35% power for 1 second.

motorSpeed(4,35);

goFor(1);

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

brake(2);

motorSpeed(1,35);

goFor(3);

12.Brake all motors for 1 second.

brake(4);

goFor(1);

13.Reverse the direction of motor one.

reverse(1);

14.Accelerate motor one from start to 19% power over 2 seconds.

celerate(1,0,19,2);

15.Run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds.

motorSpeed(2,35);

motorSpeed(1,19);

goFor(2);

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

motorSpeed(4,19);

goFor(2);

17.Decelerate both motors to 0% power in 3 seconds.

celerate(4,19,0,3);

18.Brake all motors.

brake(4);

Reflectance Sensor

1. Run all motors at a constant speed of 25% power for 2 seconds.

motorSpeed(4,25);

goFor(2);

2. 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).

motorSpeed(4,20);

goToAbsolutePosition(70.2);

3. Reverse motors.

reverse(4);

4. Run all motors at a constant speed of 30% power for 1.5 second.

motorSpeed(4,30);

goFor(1.5);

5. Brake all motors.

brake(4);

Data Analysis Tool

1. Accelerate all motors from 0% to 25% in 3 seconds

celerate(4,0,25,3);

2. Run all motors at a constant speed of 25% power for 1 second.

motorSpeed(4,25);
goFor(1);

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

4. Reverse the motors
reverse(4);

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

6. Brake all motor
brake(4);

Motor Quantity

1. Accelerate all motors from 0% to 70% in 2 seconds

celerate(4,0,70,2);

2. Run the motors to relative position of 100 marks

goToRelativePosition(100);

3. Reverse motors

reverse(4);

4. Decelerate all motors from 70% to 40% power in 2 seconds

celerate(4,70,40,2);

5. Run all motors at a constant speed of 40% power for 1 second.

motorSpeed(4,40);

goFor(1);

6. Brake all motors

brake(4);

Propeller Configuration

1. Run all motors at speed 0% then reverse

motorSpeed(4,0);

reverse(4);

2. Accelerate all motors from 0% to 70% in 2 seconds

celerate(4,0,70,2);

3. Run all motors at a constant speed of 70% power to go to relative position of 100 marks.

motorSpeed(4,70);

goToRelativePosition(100);

4. Brake all motors

brake(4);

Performance Test 1&2

1. Reverse the direction of AEV all motors.

reverse(4);

2.Run all motors at a constant speed of 60% for 6.55 seconds.

motorSpeed(4,60);

goFor(6.55);

3.Brake all motors

brake(4);

4.Reverse all motors direction and run at 68% for 1 second to stop

reverse(4);

motorSpeed(4,68);

goFor(1);

5.Reverse all motors direction and stop 8 seconds

reverse(4);

goFor(8);

6.Run all motors at constant speed of 60% for 4 seconds

motorSpeed(4,60);

goFor(4);

7.Brake all motors and let it goes for 9 seconds

brake(4);

goFor(9);

8.Reverse all motors direction and run at constant speed of 80 for 4 seconds

reverse(4);

motorSpeed(4,80);

goFor(4);

Final Performance Tests

1.AEV runs to first gate and stop for 7 seconds

reverse(4);

motorSpeed(4,60);

goFor(6.943);

brake(4);

goFor(0.2);

reverse(4);

motorSpeed(4,68);

goFor(1.5);

reverse(4);

goFor(8);

2.AEV runs and connects to the caboose

motorSpeed(4,60);

goFor(4);

brake(4);

goFor(9);

3.AEV goes back to the gate and stops for 7 seconds

reverse(4);

motorSpeed(4,90);

goFor(6.8);

brake(4);

goFor(0.1);

reverse(4);

motorSpeed(4,80);

goFor(1.6);

reverse(4);

brake(4);

goFor(8.5);

4.AEV returns to the starting position

motorSpeed(4,90);

goFor(5.3);

brake(4);

goFor(0.9);

reverse(4);

motorSpeed(4,90);

goFor(1.7);

brake(4);