Button presets

So this year we want to be able to click a button o n the controller and it will pick up a cone and drop it on the mobile goal. We are using easy c and we got it done but if we are driving then hit the button it would keep driving until it finished the program. Is there any way to make the driver gain control of what is nit running in the program or not?

Not sure how to do this in easyC, but in C programming there is something called a break statement. If you put it in an if statement inside of an infinite while loop, it’s possible to break that loop. On mobile so won’t be able to format this to the best of my ability, but this is how someone using PROS might do this in pseudocode:

{ motorSet(1, 127);
If(panic button pressed) {
break; }
motorSet(1, 0);

Again, I don’t know what easyC’s version is of


(or if it is the same or not) but hopefully this’ll point you in the right direction

That kind of helps but would the fix the problem of when press the button it keeps driving?

Yes, it should fix your code, assuming you do use while loops

If you can post your code here, I can help you figure out where to implement it

This is my if statement which is inside of a while loop.

Unfortunate easyc is not well suited to what you want to do because it cannot do multiple things at once the way RobotC can (one reason why we switched).

The problem is that you are relying on wait statements in your button code. While it is executing the steps in the button_1 if statement, it is not doing anything else, like checking what the drivetrain joystick is doing. So anything that was going on when you press button 1 will continue until it gets through all of those wait statements.

The only solution I can think of for you is to rely on timers instead of wait statements.

So basically-
-press button 1 = start timer
Then the next series of movements will not be in a big if-statement, but will rather check the timer each time through the loop and turn the motors on/off based on what time it is.

This is not a trivial change to your programming to make this work, but I think it is the only way to do this in easyc without a bunch of wait statements, which are pretty much death in a joystick program.

We thought about going to robot c do you have a picture of the code that could do something like this in robot c.

You can do this by relying on timers like @biglesliep was saying. If you were to do this in RobotC, you would create the functions using timers. Basically each function would look something like this:

void drive(int ms) {
     //reset timer here
     while(time1[T1] < ms) {
          //set all motors to drive forward

If you create each of your functions in this method, you can then add a check to the while loop like this:

 while(time1[T1] < ms && vexRT[Btn5U] != 1) 

This would then check if you want to keep moving by checking the button every time through the loop. Once it breaks out of the while loop, you can add if statements to between every function call to check if the button is being pressed, like this:

void autoDrive() {
	if(vexRT[Btn5U] == 1) {//check if the button is pressed
	if(vexRT[Btn5U] == 1) {//check if the button is pressed
	if(vexRT[Btn5U] == 1) {//check if the button is pressed
	if(vexRT[Btn5U] == 1) {//check if the button is pressed


You may have to use


instead of


. I don’t remember for sure right now.

Basically what would happen is if you pressed the button, it would break out of the loop into the main function. Before moving onto the next step, it would check if your emergency button was pressed. If so, the


would cause it to exit the whole function and give you control of the robot again.
Let me know if anything doesn’t make sense.

So would you have to hold the button the whole time to complete the program.

No, you wouldn’t. In this example, Btn5U would be your escape button that you could press during the execution of the function to exit out of it. You would just set another button in user control that would call the function, like this:
task user_control {

while(true) {
//drive control code here
if(vexRT[Btn6U] == 1) {

With this code, you would just press Btn6U to start it, and then you could press Btn5U if you want to end it early.

If you did this in RobotC, you’d use tasks, which are kind of like functions, except that they allow for multiple things to be done at the same time. You would not need to use timers. So you’d keep your button_1 code basically the same as what it does now (even with the wait statements), except you’d put it in a task, and then just start the task before the main while(true) loop.

Using tasks and avoiding timers is the real reason you’d be able to do this better/more straightforwardly in RobotC.

You can read a primer on tasks here: https://renegaderobotics.org/robotc-tasks-the-basics/
If you scroll down to the “Driver Control Example” in this article, you’ll see how this would be done in RobotC.

If you’re not going to use tasks, I would recommend a different route than what has been suggested above. They’re only giving you a few break points instead of many. For example, consider this drive forward for time (in pseudocode):

bool runProgram;
int startTime;

startTime = getCurrentTime();
if(runProgram){ // the first thing doesn’t really need the check, but this illustrates it
while(getCurrentTime()<startTime+1000 && runProgram) { // these while loops replace extended durations
if(buttonPress) {

Now you have something that keeps checking throughout the time interval instead of right at the beginning. This needn’t be for time, either; it works with encoder counts, for example. If all your stuff checks for runProgram, turning runProgram to false will end it. Just make sure you turn runProgram back to true when you start the process up again.

I just downloaded robotc for vex edr and it says it is IQ is there a way to switch the robot type

I am sure you have figured it out already, but you can switch between IQ and EDR in the menu
Robot->Platform Type->Vex 2.0 Cortex