potentiometer help

  1. 3 months ago
    Edited 3 months ago by rjnavarro

    hey i would like to know if any of the helpful people out there knew of a way to put multiple codes on a potentiometer for autonomous mode

  2. The_Original_Kev

    Mar 7 Calabasas, CA 1437Z

    what do u mean by that. Using multiple potentiometers ?

  3. @The_Original_Kev what do u mean by that. Using multiple potentiometers ?

    no just one

  4. Edited 3 months ago by rjnavarro

    like maybe if the potentiometer is turn to a specific part it will activate one code and if its tillted another way it will activate a different code

  5. The_Original_Kev

    Mar 7 Calabasas, CA 1437Z

    oh so autonomous selection ?

  6. whatwhat1

    Mar 8 31110V

    I have never done a code selector with a potentiometer but if you want I could post my LCD autonomous code selector. There are also several online resources that show some potentiometer code for this. I even believe there was a forum thread a while back about this. If you do some digging you may be able to find it :)

  7. @The_Original_Kev oh so autonomous selection ?

    yeah i think so

  8. whatwhat1

    Mar 8 31110V

    I know the way you do this though is you rotate your potentiometer to a certain point and the code then reads that since it is at x point it runs y autonomous routine.

  9. nenik

    Mar 8 V5 Beta Tester

    Say you have CASES different programs:

    int raw = SensorValue[pot]; // will get a value between 0 and 4095
    float range = (float)raw/4096; // normalize to <0,1)
    int selection = (int)(range * CASES); // your selection, 0 .. CASES-1
    switch (selection) {
        case 0:
            // call first program
            break;
        case 1:
            // call second program
            break;
        [....]
    }

    I'll let the reader figure out why the selection segments are all about the same size and why the selection stays strictly lower than CASES.

  10. can you clarify

  11. nenik

    Mar 8 V5 Beta Tester

    @rjnavarro can you clarify

    Maybe if you better clarify your question or what isn't clear in the above snippet?

  12. in the regular auton code :

    If (SensorValue[potentiometer] > 2000)
    {
         //all your regular code for auton 1
    }
    else
    {
        //all your regular code for auton 2
    }

    If the potentiometer is greater than a certain value (2000 in this case, which is about halfway through the pot's range), then when auton starts, it will go to the first auton code. If it is not greater than 2000, it will run the second code.

  13. would i be able to add a greater than and less than potentiometer?

  14. kypyro

    Mar 12 V5 Beta Tester Central Kentucky

    @rjnavarro would i be able to add a greater than and less than potentiometer?

    Of course. But properly structured, you wouldn't ever need to do that.

  15. Massey

    Mar 12 Galveston Texas 398 and 400 Teams

    If you are going to use more than two autons with asingle potentiometer I would add different color leds to verify what auton Is selected.

    We typically will use two potentiometers and run four autons.

  16. biglesliep

    Mar 13 Menlo Park, CA 1666

    If you scroll down to the "Uses" section of this article I wrote, there are some links.
    https://renegaderobotics.org/vex-sensors-potentiometer/

 

or Sign Up to reply!