Go Down

### Topic: steering question (Read 818 times)previous topic - next topic

#### kevman0044

##### Feb 21, 2011, 07:33 am
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;
}

#### AWOL

#1
##### Feb 21, 2011, 12:10 pm
Difficult to say from such a brief snippet of code (please use the # icon in the editor's toolbar when posting code), but I think you're going to need to look at "analogRead" and "map".
http://arduino.cc/en/Reference/Map
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

#### Goofballtech

#2
##### Feb 21, 2011, 04:32 pm

http://www.arduino.cc/playground/ComponentLib/Servo

#### kevman0044

#3
##### Feb 21, 2011, 08:52 pm

Go Up

Please enter a valid email to subscribe