Accelerator and brake on one potentiometer

I have an linear potentiometer with 10cm way and want build an hand steering device with brake and accelerator on this one potentiometer that at 5cm is neutral and if I'm pushing it forward it will accelerate and brake when I'm pulling it back.

Is that possible (best with the Joystick Library by MHeironimus) and if how I need to write the code?
I'm quite new to the Arduino and don't have a clue how to do so.
Btw I'm using an Arduino Leonardo if that's important.


You want pure (Newtonian) acceleration/deceleration? It's calculus... the speed increases/decreases as the derivative of the throttle position. Put a different way, the change in velocity is proportional to the throttle position. That's easy to code.

I'm not totally sure if that's already what you mean but I want the gas and the brake pedal on this single potentiometer. When the potentiometer is at 5cm nothing happens, between 5 and 10cm it's like stepping on the gas pedal (basically the W key in games but "smooth") and below 5 cm it's like steping on the brake (S key) and after stoping driving backwards.
Sorry if this wasn't clear.

If this is a passenger vehicle, you need to check the relevant regulations and laws. They are very strict. If it is a model no problem have fun!

Sorry I didn't even think about this possibility. It's only for gaming.

the pot can be read using analogRead() which returns a value 0-1023.

so assuming the midpoint of the pot is neutral, subtracting half the value will provide a value that can be positive, acceleration, or negative for braking.

  int val = analogRead (pin?) - 512;

of course val is presumably representative of a force. the de/acceleration is the true force / mass.

the translation of val to a force can be asymmetric around 0.

1 Like

Thanks, I will try out tomorrow since it's already quite late.

Edit: Tried it out today and it works fine, thanks.

I am from the automotive world and had to ask. gcjr has a good answer will that work?

What does this have to do with hand steering mentioned in OP ?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.