Potentiometer VCS C++ coding

Hello. We are trying to use a potentiometer to control the distance our arms move up and down. Does anyone have an example code using C++ VCS on programming a potentiometer? Any help would be greatly appreciated. Thanks

If you know how to program encoders (like the ones in the motors), it is very similar except the range is from 0-4095 ( about 270ish degrees of rotation).

while(ArmPot.value(degrees) <180){
     Make the arm spin
}
Stop motor
1 Like

Thank you. Is there a way that you can set a range in the code? For example: The arm rotates at 100% (Speed) from degrees 20-40. Then the arm rotates at 80% (Speed) from degrees 40-50. Any help will be greatly appreciated.

While(running){
    If(potvalue < max && potvalue>min){
        Power = 80
    }
    If(potvalue< min){.....
1 Like