Skip to main content

VEX V5 - Drive Challenge

Drive Challenge

To finish off the introduction to drive code, we set up a challenge for the robot to accomplish. The challenge is for the robot to start from a set position, drive to a specific destination, make a full turn, and then drive back to the starting position. This incorporates all aspects of basic drive code and will lead to the use of functions later.

The challenge can be modified as necessary to increase or decrease the difficulty. Below is example code of what the challenge will consist of. Make sure to set up visible markers for the robot to reach its destination using tape, vex pieces, etc.

LM.spin(fwd,50,rpm);              //left and right motors spin forward at a set rpm for 2 seconds using wait
RM.spin(fwd,50,rpm);

wait(2000,msec);

LM.stop();                                //motors are set to stop once a specific distance is achieved
RM.stop();

wait(1000,msec);                   //1 second delay for the robot so motion does not overlap and start too soon

LM.spin(fwd,50,rpm);              //point turn by spinning each motor a different direction at the same speed
RM.spin(fwd,-50,rpm);

wait(1350, msec);                  //turn for a set amount of time

LM.stop();                              
RM.stop();

LM.spin(fwd,50,rpm);         
RM.spin(fwd,50,rpm);

wait(2000,msec);

LM.stop();                    
RM.stop();

Competition Format

For our competition code this should be written in the autonomous section.


void autonomous(void) {
  LM.spin(fwd,50,rpm);              //left and right motors spin forward at a set rpm for 2 seconds using wait
RM.spin(fwd,50,rpm);

wait(2000,msec);

LM.stop();                                //motors are set to stop once a specific distance is achieved
RM.stop();

wait(1000,msec);                   //1 second delay for the robot so motion does not overlap and start too soon

LM.spin(fwd,50,rpm);              //point turn by spinning each motor a different direction at the same speed
RM.spin(fwd,-50,rpm);

wait(1350, msec);                  //turn for a set amount of time

LM.stop();                              
RM.stop();

LM.spin(fwd,50,rpm);         
RM.spin(fwd,50,rpm);

wait(2000,msec);

LM.stop();                    
RM.stop();
  }