I am trying to change up some arduino code to accept potentiometer input for variable turn rate. This is what I have right now but I can only tell it turn or dont turn. I need help adding the potentiometer part to it.
//steer one way SteerValue of 512 is straight ahead
if (k2 == 1) {
if (gangleratedeg2 < 5) { //will turn clockwise at 5 degrees per sec and if not, more power fed into steering until it does
SteerValue = SteerValue + 1;
}
if (gangleratedeg2 > 5) {
SteerValue = SteerValue - 1;
}
}
//change the 5 and -5 values if you want faster turn rates. Could use a potentiometer to control these values so would have proportional control of steering
//steer the other way
if (k3 == 1) {
if (gangleratedeg2 < -5) { //will turn anticlockwise at 5 degrees per sec and if not, more power fed into steering until it does
SteerValue = SteerValue + 1;
}
if (gangleratedeg2 > -5) {
SteerValue = SteerValue - 1;
}
}
if (SteerValue < 1) {
SteerValue = 1;
}
if (SteerValue > 1023) {
SteerValue = 1023;
}
SteerCorrect = 0;
}