Button Macros in PROS

Hi. Currently, I’m trying to program a button macro in which If button r1 is pressed, the drivetrain starts to do a set of actions. When I was testing today, the drivetrain was only moving when I would hold down the button and it didn’t seem as if it was doing the set of actions.

Can someone please explain to me as to what what is wrong with my code.

My code:

if(master.get_digital(pros::E_CONTROLLER_DIGITAL_R1)){
  translate(20,100);
  pros::delay(20);
  translate(-20 , 100);
}

Thank You

1 Like

After this line, you offer no additional delay to allow the “translate” function to occur. Also, 20 milliseconds is an incredibly short amount of time to run a macro I would think.

This is somewhat unrelated, keep in mind that if you were to put a delay directly within your driver control code, it pauses the rest of your driver control code until these translate functions finish, meaning the brain will not listen to controller input until then.

1 Like

Instead of using translate, you could use rotation to do it.