Question about switching autonomous modes

One of our mentors bought us these switches for us to switch between autonomous modes, and we think that this is an analog switch, but we’re not sure. Now, where would we hook these switches up, then how would we read a value from them in the code, and then, what would we test for, to see which autonomous mode to run. We know that digital switches have either a 0 or a 1, but how would we test for a 10 bit value, which I believe that the analog switches return. Any help is greatly appreciated.

We would really need to know more about what your switches are. In general, switches can be hooked to either the analog or digital ports, depending on what you are trying to get out of them.

If you just want an on/off signal (in terms of is each automode on or off), you can hook it to either. Then what you get into the controller (and read in in the code) for the digital ones are 0 or 1 as you mention, and for analog switches you will read in 0 or 255. If you hook the analog switch to the analog port, you will read in a range 0 to 255.

Make sure your code reads in for those switches, and then you can use the input from those switches to control your automode in the section defined in the code for automode (FIRST commented it as such, I dont have the code in front of me, so I dont remember which one it is).

Hope that helps!

At Team 245, we have a rotary, 10-number (4-bit) switch that connects via Digital IO’s.

To read in the value, define a macro AUTON_ROUTINE:


#define AUTON_ROUTINE (rc_dig_in10 | (rc_dig_in11 << 1) | (rc_dig_in12 << 2) | (rc_dig_in13 << 3))

In our case, we have our switch connected to Digital IO’s 10, 11, 12, and 13. Adjust accordingly.