Joystick to control a stepper

Hi all,

I am a new user of Arduino and don't have any experience that really counts. I am trying to use a joystick to control 2 stepper motors. I want to be able to control one motor with front and back motion and the other motor with left and right motion of the joystick. I have tried the codes available on the websites. When I try to print the values I am reading from each pot, for x and Y axes, I feel like it shows up random values. I cannot find a single position which gives (0,0) or (1023,1023). I think the joystick is not centered.
I tried use the map and constraint function to get an output between 0,255, but there is no consistency of the numbers and positions. Could someone please tell me how to center the joystick, or if I am overlooking something(most probable).

Thank you

First write a short program just to read the data from the joystick and display it on the Serial Monitor.

Does the joystick have a self-centering spring?

Assuming you have one joystick pushed half-way forward, what should the motor do when you release it?

...R

Hi,
Welcome to the forum.

What sort of control do you want with your joystick, position or speed.

Position is the stepper rotational position follows the joystick.
That is if the stick is central the stepper will always be at a specific central position
Moving the joystick will move the stepper either clockwise or counter clockwise the amount that the joystick is moved.
The joystick returning to central will make the stepper return to the specific central position.

Speed is the stepper speed is proportional to joystick position.
That is if the stick is central the stepper will stop.
Moving the joystick will move the stepper either clockwise or counter clockwise the speed of the joystick depending on how far the joystick is pushed.
The joystick returning to central will stop the stepper.

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks… Tom… :slight_smile:

With the joystick in its centre position, the digital readings should be roughly (512,512).

You should get (0,0), (0,1023), (1023,0) and (1023,1023) when the joystick is pushed fully over to the corners of its travel.

Most small joysticks have a dead band near the centre position so you have to move the knob several degrees from the centre position before the voltage from each potentiometer start to change. There are also likely to be dead bands near the end stops, so the digital reading will be 0 or 1023 before the joystick knob reaches the ends of its travel.

If you have a meter, check the voltages from each potentiometer.

(I am making certain assumptions, including about how you have wired up your joystick.)