Controlling two servos with a thumbstick, servos center with thumbstick

I don’t have any experience writing code, and I’m trying to program a thumbstick to control two servos for aiming a pneumatic cannon. I’ve run into the problem that the servos center with the thumbstick (as they follow the thumbstick’s movements, which centers when you let go of it). I have no idea what code I should add to stop this from happening, and I was wondering if anyone could help me fix this. I have attached my code to this post. If anyone could give me an example as to what instructions I should add to this code, I’d be very grateful.

Kanon_Programma_Met_Pins.ino (1.79 KB)

That's what is supposed to happen. The servos follow the thumbstick/joystick position. If it centres so do they.

If you want to move the servos to a position and then stay in that position until you decide to fire you could use another switch, perhaps a "hold" switch", to say that. Otherwise how will the program know when the servos are supposed to follow the stick movement and when not?

Steve

This Thread shows how to make the servos stay in position.

...R

You could remove the return springs on the joystick so it stays where you put it.

johnwasser:
You could remove the return springs on the joystick so it stays where you put it.

That is not necessary IMHO. The problem can be dealt with in software.

...R