Arduino Function Glossary
All functions were created and adopted from the Preliminary R&D guide (P R&D),
- celerate(m,p1,p2,t) – accelerates or decelerates the input motor (denoted m) from the initial power (denoted p1) to the final power (denoted p2) across a given amount of seconds (denoted t). Input 4 for m to accelerate all motors
- goFor(t) – maintains the last state of the motors for t seconds
- brake(m) – brakes the input motor. Input 4 to brake all motors
- reverse(m) – reverses the input motor. Input 4 to reverse all motors
- goToRelativePosition(n) – continues the previous command for n marks (1 mark = .4875 inches) from the vehicles current position. The variable n can be positive or negative. Positive denotes a distance of n marks in front of the AEV while negative denotes a distance n marks behind the AEV.
- goToAbsolutePosition(n) – Continues the previous command for n marks relative to the overall starting position of the AEV.
Preliminary R&D Activity 1 Arduino C0de
//accelerate motor 1, from 0% to 15%, over 2.5 sec
celerate(1,0,15,2.5);
//run last command (motor 1 at 15% power) for 1 sec
goFor(1);
//brake motor 1
brake(1);
//accelerate motor 2, from 0% to 27%, over 4 sec
celerate(2,0,27,4);
//run last command (motor 2 at 27% power) for 2.7 sec
goFor(2.7);
//decelerate motor 2, from 27% to 15%, over 1 sec
celerate(2,27,15,1);
//brake motor 2
brake(2);
//reverse motor 2
reverse(2);
//accelerate all motors, 0% to 31%, over 2 sec
celerate(4,0,31,2);
//accelerate all motors, 0% to 35%, over 1 sec
celerate(4,31,35,1);
//run last command (all motors at 35% power) for 1 sec
goFor(1);
//brake motor 2
brake(2);
//accelerate motor 1, 35% to 35%, over 1 sec
celerate(1,35,35,1);
//run last command (motor 1 at 35% power) for 3 sec
goFor(3);
//brake all motors
brake(4);
//run last command (brake all motors) for 1 sec
goFor(1);
//reverse motor 1
reverse(1);
//accelerate motor 1, 0% to 19%, over 1 sec
celerate(1,0,19,1);
//accelerate motor 2, 0% to 35%, over 1 sec
celerate(2,0,35,1);
//run last command (motor 2 at 35% power) for 2 sec
goFor(2);
//decelerate motor 2, 35% to 19%, over 1 sec
celerate(2,35,19,1);
//run last command (motor 2 at 19% power) for 2 sec
goFor(2);
//decelerate motor 1, 19% to 0 %, over 3 sec
celerate(4,19,0,3);
//brake all motors
brake(4);
Preliminary R&D Activity 2 Arduino C0de
//Exercise 2
//Reflectance sensor test
reflectanceSensorTest();
//Set all motors to 20% power
motorSpeed(4,20);
//Move the AEV 30 marks forward from the current position
goToRelativePosition(30);
//Run all motors at a constant speed of 25% power for 2 seconds.
celerate(4,0,25,2);
//Set all motors to 20% power
motorSpeed(4,20);
//Go to the position at mark 295 on the track (approx. 12 feet)
Preliminary R&D Activity 3 Arduino Code
Advanced R&D 1 Arduino Code
//Advanced R&D Exercise 1
//—————————————————-
//Preliminary Reflectance Sensor Test
//Reflectance sensor test
reflectanceSensorTest();
//—————————————————-
//Start Activation Sequence
//Set all motors to 0% power
motorSpeed(4,0);
//Go to the position 16 marks behind current position
goToRelativePosition(-16);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
//Begin Low Power Test
//Set all motors to 30% power
motorSpeed(4,30);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
//Begin Medium Power Test
//Set all motors to 35% power
motorSpeed(4,35);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
//Begin High Power Test
//Set all motors to 40% power
motorSpeed(4,40);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
Advanced R&D 2 Arduino Code
//—————————————————-
//Start Activation Sequence
//Set all motors to 0% power
motorSpeed(4,0);
//Go to the position 16 marks behind current position
goToRelativePosition(-16);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
//Trial 1 with Caboose
//Set all motors to 35% power
motorSpeed(4,35);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
//Trial 2 Test with Caboose
//Set all motors to 40%power
motorSpeed(4,40);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
// Trial 3 with Caboose
//Set all motors to 45%power
motorSpeed(4,45);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
//Trial 4 with Caboose
//Set all motors to 50%power
motorSpeed(4,50);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//—————————————————-
//Trial 5 with Caboose
//Set all motors to 55%power
motorSpeed(4,55);
//Go to the position 100 marks away from the AEV
goToRelativePosition(100);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
Advanced R&D 3 Arduino Code
Test 1 Code – Friction Cover Slide Distance
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//Set all motors to 45% power
motorSpeed(4,45);
//Continue last command (motors at 45% power) for .5 seconds)
goFor(.5);
//gradually increase motor power from 15 to 45%
//for(int i = 25; i <= 45; i++) {
//
// celerate(4,i,i+1,.05);
//
//}
//
//brake(4);
//Set all motors to 25% power
motorSpeed(4,25);
//Go to the position -20 marks away from the AEV
goToRelativePosition(-20);
//Set all motors to 30% power
motorSpeed(4,30);
//Go to the position -20 marks away from the AEV
goToRelativePosition(-20);
//Set all motors to 35% power
motorSpeed(4,35);
//Go to the position -20 marks away from the AEV
goToRelativePosition(-20);
//Set all motors to 40% power
motorSpeed(4,40);
//Go to the position -20 marks away from the AEV
goToRelativePosition(-20);
//Set all motors to 45% power
motorSpeed(4,45);
//Go to the position -20 marks away from the AEV
goToRelativePosition(-20);
Test 2 Code – Friction Cover and Slide Distance
//AR&D 3 Test 1
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds)
goFor(2);
//Set all motors to 0% power
motorSpeed(4,45);
//Continue last command (motors at 0% power) for 2 seconds)
goFor(5);
Performance Test #1 Arduino Code
The if statement was not used and will require further testing before we decide whether to incorporate it or not.
//Performance Test 1
//Stop running at mark 266.6667
//13 is start. 157 is beginning sensor
//Reverse all motors
reverse(4);
//Set all motors to 35% power
motorSpeed(4,30);
//Go to the relative postition
goToRelativePosition(243);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
////Continue last command (motors at 0% power) for 2 seconds)
//goFor(2);
////If the vehicle undershot the sensor, go to the sensor at 30% power
//if (getVehiclePostion() < 295) {
// motorSpeed(4,30);
// goToRelativePosition(295 – getVehiclePostion());
//}
//Continue last command (motors at 0% power) for 7 seconds
goFor(8);
//Set all motors to 35% power
motorSpeed(4,30);
//Go to the relative postition
goToRelativePosition(243);
Performance Test #2 Arduino Code
//Performance Test 2
//Stop running at mark 266.6667
//13 is start. 157 is beginning sensor
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//Reverse all motors
reverse(4);
//Set all motors to 35% power
motorSpeed(4,35);
//Go to the relative postition 222 marks away from the AEV
goToRelativePosition(222);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 8 seconds
goFor(8);
//Continue after gate
//Set all motors to 40% power
motorSpeed(4,40);
//Continue last command (motors at 40% power) for .25 seconds
goFor(.25);
//Set all motors to 35% power
motorSpeed(4,35);
//Go to the relative postition 218 marks away from the AEV
goToRelativePosition(218);
//Connect to caboose, wait, then leave load zone
//Reverse all motors
reverse(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds)
goFor(5);
//Set all motors to 45% power
motorSpeed(4,45);
//Continue last command (motors at 45% power) for 2 seconds)
goFor(2);
________________________________________________________________________________
Performance Test #3 (Final Performance Test) Arduino Code
Trial 1 Code
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
goFor(2);
//Reverse all motors
reverse(4);
//Set all motors to 35% power
motorSpeed(4,35);
//Go to the relative postition 270 marks in front of the vehicle
goToRelativePosition(268);
//Brake all motors
brake(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Set all motors to 35% power
motorSpeed(4,45);
//Set all motors to 35% power
motorSpeed(4,45);
//Go to the relative postition 227 behind the vehicle
goToRelativePosition(233);
Trials 2 and 3 Code
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds
//goFor(2);
//Reverse all motors
reverse(4);
//Set all motors to 35% power
motorSpeed(4,35);
//Go to the relative postition 271 marks in front of the vehicle
goToRelativePosition(269);
//Go to the relative postition 225goToRelativePosition(229);
//Set all motors to 35% powermotorSpeed(4,25);
//Go to the relative postition 57goToRelativePosition(61);
//Reverse all motors
reverse(4);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 2 seconds)
goFor(5);
//Set all motors to 0% power
motorSpeed(4,45);
//Go to the relative postition 224 marks in behind of the vehicle
goToRelativePosition(227);
//Set all motors to 0% power
motorSpeed(4,0);
//Continue last command (motors at 0% power) for 7 seconds
goFor(8);
//continue after the gate on the way back
//Set all motors to 35% power
motorSpeed(4,45);
//Set all motors to 35% power
motorSpeed(4,45);
//Go to the relative postition 240 behind the vehicle
goToRelativePosition(242);