Spider 2 servos, extender and a joystick fun

Today i had a pan and tilt head arrive. 2 9g servos and brackets. I decided to do a little project that drives the X and Y servos from a joystick.
Within 1 hour i had the thing built, hooked up to the breadboard and working using 2 PWM pins on the extender. its not smooth motion yet but it works.

I LOVE Gadgeteer !!! :slight_smile:

We believe it when we see it. :wink:

Let us share the fun with you. Shoot a video of what you made for us :slight_smile:

Ha ha good point. Video will be up tomorrow. I have to create a YouTube account first .
Bed time for me now though.

As promised, sorry about the poor quality of the Vid but i couldnt hold my phone the joystick and the bottom servo all at the same time :slight_smile:

At the moment there is not smoothing on the values i get back from the joystick so the servos jitter somewhat. I will figure that out as i get to it.
But the key thing for me here is that when i sat down to do this last night i didnt expect that i would achieve a working model.
I am basically using a timer to check the values of the joystick every 50ms and then convert them to the pulse etc.
Is it possible to use an X or Y value change as an interupt and drive it that way?

Now, we are talking! Good start!

As another approach you can run a thread that will monitor X and Y and will fire events that you will respond to accordingly.

Thanks Architect. I will look into that. I do need to work out how to smooth the values coming from the joystick, its really noisy and makes the servos jitter quite a lot. I am guessing a little avaraging algorithm might work or just taking the first set of digits i.e 0.5 (the range seems to run from 0 to 1)

When I did something similar I found I was getting noise from dodgy connections due to trying to clip the servo connector onto the ‘short end’ of breakaway header pins plugged into the breadboard, once I got myself double-sided header pins (long on both sides) I got a much better connection with less noise. Also make sure to incorporate a ‘dead zone’ around the 0.5 centre values so that anything between, say, 0.45 and 0.55 gets treated as dead-on 0.5, in order to prevent any jitter while you’re not touching the stick.

Please share the code. Please I need more joystick examples. Thanks

@ RorschachUK, thats a good idea. A dead zone would actually solve the problem nicely. Im not sure the noise is comming from the connections as i am debug.printing the X and Y positions comming from the Joystick and you are right they float between around 0.45 and 0.55.

@ Swestcott, as soon as i have it working nicley i will post the code.

You may want to use/borrow from my Joystick driver at