Why can't I have both auton & driver mode on the same template?

My driver mode and auton are both on the same template and my auton will work but my driver mode will not. I am using vex code blocks and am confused on how to get both to work on the same template.


All your driver control code should be under a single “when driver control” block. That code should contain an infinite loop that reads controller values and assigns power to motors as needed.


I appreciate you helping me

I am just confused on how I would get the controls to work when it is under a “when driver control” block. I thought that I could use “When (specific button) pressed (X) happens.” I am fairly new to vex coding so sorry about the confusion.

If you’re not using competition control, that should work fine (as you may have already discovered).

But, when using a robot in competition, different parts of your code have to be started and stopped at different times. As such, your program needs to know what parts of the code should run during autonomous and what parts should run during driver control - that’s what the “when autonomous” and “when driver control” blocks are for. Any code that’s not under one of those blocks will not be run when your robot is connected to a competition control system.

So, how do you write driver control code that looks like this? The general approach is to have an infinite loop, and every time through the loop, you write values to motors based on values read from the controller. Here’s an example:

33 PM

This code spins Motor1 at variable speed based on controller axis 1, and spins Motor2 when the controller up button is pressed.

You can add additional code within the loop to control additional motors.


This makes a lot more sense. Thank you very much! :smile: