How to set up mutiliple programs based on field location

During last year’s competitions, I was able to see that teams were able to create switches for their robot which told the robot what to do based on their location on the field. Does anyone now how this is done or any clue about it or as to where to get information about such a thing? Is it electrical wiring or programming?

For example press a switch (or flip a switch) “A” (out of three) and the robot does only the things programmed for that switch.

The typical way to do this is to read the switches (whether on the robot or the Driver Station) at the beginning of Autonomous mode, then use a Case Structure to choose which code to run based on the input.

You can see an example of this behavior in the default Autonomous code. It is setup to use 2 switches attached to the Cypress PSOC on the Driver Station in order to select between straight, left Y or right Y. In the default code the Case Structure only effects a small portion of the code, but it is often wrapped around a larger chunk of code to switch between very different autonomous modes.

Thank you.