Program Basics: Previous Codes

SCENERIO 1 CODE

void myCode()
{
//—————————————————————————————-
// myCode();
//
// This is the tab where the programming of your vehicle operation is done.
// Tab _00_AEV_key_words contains a compiled list of functions/subroutines used for vehicle
// operation.
//
// Note:
// (1) After running your AEV do not turn the AEV off, connect the AEV to a computer, or
// push the reset button on the Arduino. There is a 13 second processing period. In
// post processing, data is stored and battery recuperation takes place.
// (2) Time, current, voltage, total marks, position traveled are recorded approximately
// every 60 milliseconds. This may vary depending on the vehicles operational tasks.
// It takes approximately 35-40 milliseconds for each recording. Thus when programming,
// code complexity may not be beneficial.
// (3) Always comment your code. Debugging will be quicker and easier to do and will
// especially aid the instructional team in helping you.
//—————————————————————————————-

// Program between here——————————————————————-

// Starting Template———————————-
/*
// Run motor one at a constant speed (23% power) for 2.5 second.
motorSpeed(1,23);
goFor(2.5);

// Brake motor one.
brake(1);
*/

// EXERCISE 1—————————————–
/*
// Accelerate motor 1 from 0 to 15% power in 2.5 seconds
celerate(1,0,15,2.5);
// maintain motor 1 at 15% power
motorSpeed(1,15);
// Run for 1 second
goFor(1);
// Brake motor 1
brake(1);
// Accelerate motor 2 from 0 to 27% power in 4 seconds
celerate(2,0,27,4);
// Run motor two at a constant speed 27% power for 2.7
motorSpeed(2, 27);
// Run for 2.7 seconds
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 0 to 31% power in 2 seconds
celerate(4, 0, 31, 2);
// Run all motors at a constant speed of 35% power for 1 second
motorSpeed(4,35);
// Go for 1
goFor(1);
// Brake motor 2
brake(2);
// go for 3 seconds
goFor(3);
// Brake all for 1 second
brake(4);
// brake for one second
goFor(1);
// Reverse the direction of motor 1
reverse(1);
// Accelerate motor 1 from start to 19% power over 2
celerate(1, 0, 19, 2);
// Run motor 2 at 35% power at the same time motor 1 is at 19% power for 2 seconds
motorSpeed(2, 35);
motorSpeed(1, 19);
// go for 2 seconds
goFor(2);
// Run both motors at a constant speed 19% power for 2 seconds
motorSpeed(4, 19);
// go for 2 seconds
goFor(2);
// decelerate both motors to 0 in 3 seconds
celerate(4, 19, 0, 3);
// brake all
brake(4);
*/

// Reflectance Test ————————————–
// reflectanceSensorTest();

// EXERCISE 2———————————————
/*
// Run both motors at 25% for 2 seconds
motorSpeed(4, 25);
// go for 2 seconds
goFor(2);
// Run all motors at constant speed of 20% and travel a distance of 12 feet from the starting point
motorSpeed(4, 20);
goToAbsolutePosition(24.6);
// Revers both motors
reverse(4);
// Run both motors at 30%
motorSpeed(4, 30);
// go for 1.5 seconds
goFor(1.5);
// Brake all motors
brake(4);
*/

// Exercise 4 ——————————————–
celerate(4, 0, 25, 3);
goFor(1);
motorSpeed(4,20);
goFor(2);
brake(4);
reverse(4);
motorSpeed(4, 25);
goFor(2);
brake(4);

// And here——————————————————————————–

} // DO NOT REMOVE. end of void myCode()