How to code an autonomous swapping button

Idk how to code a button that swaps between our different autos. I also want it to display on the brain saying “Right side auto” or “left side auto” I’m too dumb to figure it out so can someone help. Also I code in blocks sooo…pls help my team had to re download our auton every time we needed to switch it last year.

2 Likes

You can use a limit switch. Each time the button is pressed, it will run the next auton. And you can assign that value to a variable and when the auton runs it will run the auton with that variable number

2 Likes

There isn’t a way to do this using block code. As @Penguin1 mentioned, you could use a limit switch. However, what our team did when we used block code is we downloaded each autonomous routine as a different program on the brain. That way, we could select which routine to run simply by clicking Programs, then the program we wanted. To do this click the button next to the name of your project titled “Slot”, then select a different slot for each program.

Screenshot 2024-11-11 220935

3 Likes

I think there is:

I believe Variables are available project wide in Blocks. So you could set a number of virtual buttons for your configuration - in the example only two - red blue… This gets run before match has started.

@jpearman built an example of 8 buttons in C++ way back when… I tweaked it in a different way back then. If I am correct in this, I can make an example similar to what we did for Turning Point./

4 Likes

thank you for all of the tips guys. this will make this season so much easier :slight_smile:

2 Likes

I was not aware of that! It’s been a while since I used block code lol.

3 Likes

I cleaned up my Blocks example into a two choice autonomous routine. You can extend to as many choices, but you will have to make the graphical user interface for your application.

Mr C - Two Choice Autonomous.pdf (535.7 KB)

1 Like

Idk if I’m doing it wrong but every time I change the code in lets say slot 1 for example, it will make that same change in all other slots.