I am quickly making a auton switch for my robot (a day before worlds LOL) but i forgot how to program it. Using IF statements in EasyC how do i correctly right the statement for the ranges of the potentiometer. For Example how would i write this is code: If potentiometer is bigger or equal to 0 but smaller or equal to 35.
Well i am using a potentiometer for 3 different so it has to be like within ranges of numbers
if(pot<400) autonOne(); else if (pot>400&&pot<700) autonTwo(); else autonThree();
Not sure what the differences between easyc and robotc, but our code looks similar to
If [potientiometer] >= 100
run leftside auto
else if [potientiometer] <= 100 && [potientiometer] >= 200
else if [potientiometer] <= 200 && [potientiometer] >= 300
not sure I’m just pulling this off the top of my head
This should work.
Thanks, also you do u know the range (number that is shown on the online window to test) of the potentiometer? Like 0 to what? I know that the degree of the sensor is 250 degrees, but i dont know the actual number range
it goes to 1024
So the actual number shown on the online window at its maximum is 1024? and all the way down to zero?
Sorry, i don’t know the ranges since I’ve always used the lcd to select autonomous routines.
This is from the reference pdf:
The Potentiometer is used to measure the angular position of the axle or shaft passed through
its center. The center of the sensor can rotate roughly 265 degrees and outputs values ranging
from 0-1023 to the VEX PIC and 0-4095 to the VEX Cortex.
Use the debugger to make acceptable ranges for your selector. Find the parts that align with the marks and then divide the range in two. I’ve seen up to twelve autons selected in a it over 180 degrees with no problem. They could have done more but did not need to.
Make sure the selector has the full range for all your marks, and tighten down the pot and the thing with the marks with nylocks so it does not shift. That can be bad. Seen that one the hard way.