How do you program a potentiometer to run a program when the potentiometer angle reaches a certain value? I am using VEX Code pro v5. Thanks!
For something like this, you would get the value for the potentiometer and compare it with your target value inside an if statement.
for example:
if(potentiometerValue > 45) {
//do something when the potentiometer's value is more than 45
}
This could also be applied to a range of values:
if(value > 10 && value < 20) {
//do something
}
Or you could have multiple states:
if(value > 10) {
//result 1
}
else if(value > 20) {
//result 2
}
else {
//result 3
}
4 Likes