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 sleep
RM.spin(fwd,50,rpm);

task::sleep(2000);

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

task::sleep(1000);                   //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(reverse,50,rpm);

task::sleep(1350);                  //turn for a set amount of time

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

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

task::sleep(2000);

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