Autonomous selection using jumpers

Hello, I’ve been trying to create four autonomous programs and have them selected by which port I place the jumper in. How would this be done? Example programs definitely help too. Thanks for any help :slight_smile:

I can build this for you. How would you like it to work? Like, what combination of jumpers and digital ports? For example:

Program 1 should be started when no jumpers are inserted
Program 2 should be started when a jumper is in Digital Port 1
Program 3 should be started when a jumper is in Digital Port 2
Program 4 should be started when a jumper is in Digital Port 1 and 2

Would be a way of doing this. But I don’t know what sensors you are already using, or how many Jumpers you have/how many you want to use. If you tell me that, I can build you basically the program you want without needing many tweaks on your end.

EDIT: This is EasyC you mean, right? Otherwise just use Pearman’s thing below

Here’s one way using two jumpers.

#include "Main.h"

void Autonomous ( unsigned long ulTime )
    int jumper1; 
    int jumper2; 
    int autonSelect; 

    jumper1 = GetDigitalInput ( 1 ) ; // read the first jumper in digital port 1
    jumper2 = GetDigitalInput ( 2 ) ; // read the second jumper in digital port 2
    // combine the two jumpers into a variable
    // this variable will have the value 0, 1, 2 or 3
    // as jumper 1 can be 0 or 1 and jumper 2 can be 0 or 1
    autonSelect = (jumper1 * 2) + jumper2 ;
    // Now select the auton code based on that variable 
    switch ( autonSelect )
        case 0 :
            // run autonomous routine 1 here 
            break ;
        case 1 :
            // run autonomous routine 2 here 
            break ;
        case 2 :
            // run autonomous routine 3 here 
            break ;
        default : // anything not 0, 1 or 2
            // run autonomous routine 4 here 

If you have the digital ports available, another nice thing to do is to put LED lights in two other ports to mimic the jumpers you put in. Putting LED’s around the jumpers limits the mistakes and gives a positive feedback you did it right.

Those digital ports can be kind of tricky to get the jumper in the right slots at times.

When doing your code selection code, just send some more code to light or unlight the right LED’s in the other ports.

All of this can be done in the pre_auton routine too so you can do it before the robot is ever started in the competition.

If you make a function out of this initialize jumper routine, you could call it in pre_auton, then call it again in auton, and then again at the start of driver control. It’s just a few milliseconds at most so it’s not using a ton of compute cycles. Putting it in the loop of driver control will allow you to debug this function.

I’m attempting to do this in easy C by the way.

Here’s the program you asked for. Sorry, I got caught up playing Civ 5 last night, and just got around to this now.

This should work. I think. I haven’t used jumpers in a while, but I think this is how they responded when we used them last year.
Jumper Switch (2.55 KB)

Ok thanks. I added it today and Thursday I’m going to be doing more tests… thanks for the help.