Jumper Programming

So I was trying to figure out how to switch between autonomous’ (Automi?) and I found some jumper clips. I tried for a really long time to find out how to code these things.I found a few tutorials, but they were all easyC (I use RobotC). Does anyone know how to program a jumper clip to change between Automi, In robotC?

what do jumper clips do?

Well the purpose I am using it for is to switch between Automi (One when it is in, one when it is out)
I believe it can do other things also, though.

Set the appropriate port(s) to Digital In in your Motors and Sensors Setup. Then just use


SensorValue]

as normal – it will return 1 or 0 depending on whether you have a jumper in the specific port addressed.

Jumpers are a way to tell the Cortex a binary value, just like a switch.

You can plug them in to one of the twelve digital ports and use SensorValue[myJumper] to read the value. However, you can also use an analog port as a jumper port.

If you use a digital port, the setup in Motors and Sensor Setup looks like this:

Note that you can either set the sensor type to “Digital In” or “Touch”; either way will work.

If you use an analog port, the setup in Motors and Sensor Setup looks like this:

Here, just set the sensor type to “Analog”.

No matter which port or setup you choose, the absence of the jumper will read as a zero, and the presence of the jumper will read as non-zero.

So, you can do something like this:

if (SensorValue[myJumper] > 0)
{
    // Jumper is present
   // Run the code for Autonomous 1
}
else
{
    // no Jumper in the port
   // Run the code for Autonomous 2
}

You can use jumpers as input for many different purposes. That code illustrates just one.

You can even gang jumpers together for 2^N combinations (if you manage to plug them in properly.
Think of (warning: untested code):


    int selection = 4 * SensorValue[jumper2] + 2 * SensorValue[jumper1] + SensorValue[jumper0];
    switch (selection) {
        case 7: ....
            break;
    }

As a side note, it’s also common practice to use a potentiometer with a dial to select between autonomous routes. Simply say “when between 0 and 500, goto A, when between 500 and 1000, goto B, etc…” We often use a label maker to help us remember where each program is located on the range.

An example from our robot last year is below. The standoffs are to ensure it doesn’t go out of range.

We use ours to switch between control schemes. This is because I drive for matches, our builder drives for skills. If you would like, I can give an example of how you would program that.

While we are talking about switching autonomous… LCD menus are a great way to allow hundreds of variations or choices and to allow robot configuration on the field (in conjunction with some flash saving/loading).

And while we are at it, sensors that can automatically determine which autonomous to run based on a range of possibilities are ideal - as there is no need to set an autonomous before each match. Though it can be important to have a manual override :wink: