how can I code when I pressed a button change my motors speed and when I pressed another button it would go back to its regular speed?
if button pressing, var = low
if button2 pressing, var = not low
motor spin at power var
my bad I wasn’t clear I meant if buttonA.pressed how would I use that to change the speed
{i’ll rewrite my question}
if buttona.pressing()
speed
if not
don’t speed
The .pressed() method is probably what you would want to use. You can have a variable that stores the speed, read when the button is pressed, and swap the speed. The .pressed() method runs once after the button has been released, meaning you won’t loop swapping the values.
how can I use the pressed method
Please, be aware that .pressed() function uses callbacks and is only good for advanced coders. It is very easy to mess up with callbacks.
https://api.vexcode.cloud/v5/html/classvex_1_1controller_1_1button.html
If you decide to use .pressed() instead of much simpler .pressing() function, then you can find very helpful this mini-tutorial:
Also, you may find this topic similar to what you are doing: How to change turn velocity by 5% with a button press - #6 by weilin