how to move 2 servo's using a Joystick

Hello,

I have a problem with the program I wrote.
Whene I move the joystick the servo move’s but whene I let it go the servo move’s back to his starting
position and that’s not what I want.
I want it to stay in that position.

can someone help me? Please?
Thanks in advance.

This is the program.

#include <Servo.h>

const int SERVOX=9;
const int SERVOY=10;
const int POTX=0;
const int POTY=1;

Servo myServox;
Servo myServoy;
int valX=0;
int valY=0;
void setup()
{
myServox.attach(SERVOX);
myServoy.attach(SERVOY);
}

void loop()
{
valX=analogRead(POTX);
valX =map(valX,0,1023,0,179);
myServox.write(valX);
delay(20);

valY=analogRead(POTY);
valY=map(valY,0,1023,0,179);
myServoy.write(valY);
delay(20);
}

There are certainly ways to do what you're after, but can I ask how you define the difference between the joystick travelling back to the centre in a movement you want to ignore, and the joystick travelling back nearer the centre on purpose, in a way you want to record?

Congratulations, it's twins! how to move 2 servo's using a Joystick

Thread locked. Cross-post.

DO NOT CROSS-POST, CROSS-POSTING WASTES TIME.