How to increment servo angle degree in Arduino using a joystick

I know how to increment the angle of a servo using a potentiometer. I want the servo to hold its degree even after I let go of the joystick and the joystick springs back to its default position. But the problem is that when the joystick springs back so does the servo. I want the servo to hold its last human input. I am not sure of what model joystick is, but it looks like this:

The servo is an MG996R

Can you please help me? Thanks.

So, when the servo stays at the target angle, how & when do you get it to make another movement ?

I'm wondering if the code you have actually does increment: if you used the standard servo knob example, that doesn't increment as such, it maps the pot to the servo and that sounds like what you have. It certainly would have the symptom of returning the servo to 0 when the joystick returns to the middle. Incrementing is actually what you want, but it's not what you have!

The sketch in this thread should do the trick.

1 Like

Yes, my original was code was mapping the joystick, but I noticed every time I let go of the joystick the servo would move back to the reading analog position of the joystick. I would like to thank you sooo much, the thread you have shown me is soo helpful and solved my problem. Thanks to people like you forums like this work. :slight_smile:

I think I just had more luck with a forum search than you did?

2 Likes

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