Arduino Codes

Codes

Performance Test

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——————————————————————-
//Motor 1 is the front mounted motor
//Motor 2 is the back mounted motor
reverse(2);
motorSpeed(4,30); //prev 27
//goFor(5);
//brake(4);
goToAbsolutePosition(265.84);//prev 285.84
brake(4);
reverse(4);
motorSpeed(4,35);
goFor(1.5); //prev 2
brake(4);
goFor(7); //7.5
reverse(4);
motorSpeed(4,30); //prev 27
goToAbsolutePosition(456.41); //prev 496.41
brake(4);
//goFor(2);
reverse(4);
//motorSpeed(4,30);
//goFor(.5);
//brake(4);
goFor(8); //prev 7

motorSpeed(4,55); //prev 50
goToAbsolutePosition(400.84); //prev 398.84

brake(4);
reverse(4);
motorSpeed(4,55); //prev 60
goFor(1.5); //prev 1.9
brake(4);
reverse(4);
goFor(7); //prev 7.5
motorSpeed(4,55);//prev 50
goToAbsolutePosition(210); //prev 150
brake(4);
goToAbsolutePosition(60); //prev 100
reverse(4);
motorSpeed(4,50); //prev 60
goFor(1.5); //prev 2
brake(4);

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

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



One-motor Configuration

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-------------------------------------------------------------------
 
/*
* Strangely, this program worked without a reverse command
*/

 motorSpeed(4,52.5); //set motor to 52.5 percent power (needs more more to overcome the force of friction)
 goFor(5); //continue for 5 seconds
 brake(4); //stop the motor
// And here--------------------------------------------------------------------------------

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

Two-motor Configuration

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-------------------------------------------------------------------
 
 reverse(4); //set correct direction of motors
 motorSpeed(4,35); //set all motors to 35 percent power
 goFor(5); //continue for 5 seconds
 brake(4); //stop all motors
// And here--------------------------------------------------------------------------------

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

Coasting
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-------------------------------------------------------------------
 reverse(4); //set correct direction of motors
 motorSpeed(4,35); //set all motors to 35 percent power
 goToAbsolutePosition(-73.8); //go forwards 3 feet
 brake(4); //stop all motors
// And here--------------------------------------------------------------------------------

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

Power Braking
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-------------------------------------------------------------------
 
 reverse(4); //used to set motors in correct direction
 motorSpeed(4,35); //set all motors to 35 percent power
 goToAbsolutePosition(-276.8); //go 11 feet forward
 motorSpeed(4,35); //set motor speeds again as the Arduino sets them to 0 when the previous command finishes
 reverse(4); //reverse direction of motors
 motorSpeed(4,35); //set motor speed again
 goFor(5); //start braking by spinning the motors in the opposite direction for 5 seconds
 brake(4); //stop all motors
// And here--------------------------------------------------------------------------------

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

Lab 4

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-------------------------------------------------------------------

celerate(4,0,25,3);     //accel all motors to 25% power in 3 seconds
 goFor(1);                    //continue at 25% power for 1 second
 motorSpeed(4,20);  //set all motors to 20% power
 goFor(2);                  //continue all motors at 20% power for 2 seconds
 reverse(4);              //reverse all motors
 motorSpeed(4,25); //set all motors to 25% power
 goFor(2);                  //continue all motors at 25% power for 2 seconds
 brake(4);                 //brake all motors

// And here--------------------------------------------------------------------------------

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

Lab 2

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-------------------------------------------------------------------

motorSpeed(4,25); //set all motors to 25% power
 goFor(2);                 //run all motors for 2 seconds
 motorSpeed(4,20); //set all motors to 20% power
 goToAbsolutePosition(299.533); //go 12 feet from starting point
 reverse(4);               //reverse all motors
 motorSpeed(4,30); //set all motors to 30% power
 goFor(1.5);              //continue for 1.5 seconds
 brake(4);                //brake all motors

// And here--------------------------------------------------------------------------------

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

Lab 1

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-------------------------------------------------------------------

celerate(1,0,15,2.5); //accel motor 1 to 15% power in 2.5 seconds
 goFor(1);                   //continue at 15% power for 1 second
 brake(1);                   //brake motor 1
 celerate(2,0,27,4); //accel motor 2 to 27% power in 4 seconds
 goFor(2.7);              //continue at 27% power for 7 seconds
 celerate(2,27,15,1); //decel motor 2 from 27% to 15% power in 1 second
 brake(2);                //brake motor 2
 reverse(2);              //reverse direction of motor 2
 celerate(4,0,31,2); //accel all motors from 0 to 31% power in 2 seconds
 motorSpeed(4,35); //set all motor powers to 35%
 goFor(1);                   //continue at 35% power for 1 second
 brake(2);                 //brake motor 2
 goFor(3);                //let motor 1 run at 35% power for 3 seconds
 brake(4);               //brake all motors
 goFor(1);               //pause for 1 second
 reverse(1);            //reverse direction of motor 1
 celerate(1,0,19,2); //accel motor 1 to 19% power in 2 seconds
 motorSpeed(2,35); //set motor 2 at 35% power
 goFor(2);                 //continue for 2 seconds
 motorSpeed(1,19); //set motor 1 to 19% power
 goFor(2);                //continue for 2 seconds
 celerate(4,19,0,3); //decel all motors to stop in 3 seconds
 brake(4);               //brake all motors
 // And here--------------------------------------------------------------------------------

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