Joystick Servo Control... for newbies.

Hello. I have a project whereby a servo needs to be controlled by a joystick, and I'm wondering if an Arduino could be used here.

I saw this guide: http://teamprincipia.wordpress.com/2008/04/08/arduino-python-4-axis-servo-control/ (and the previous 2 articles on the site as well) which explain how to connect a joystick to a PC, and then connect a servo to an Arduino and get some Python code to tie it all together. This is almost exactly what I need... but with no PC in the loop.

I've seen this forum post: http://arduino.cc/forum/index.php/topic,5080.msg38890.html#msg38890 but the conversation kinda drifted off in other directions.

I'm really really new to this, but can I use a USB host shield to connect the joystick to the Arduino, then store some code on the Arduino that will let me do what I want?

Any tips/suggestions gratefully received!

Does it have to be a USB joystick? It's generally easier to interface to a raw joystick potentiometer than to go through USB.

I would suggest you connect the joystick potentiometer directly to the Arduino analog input (and the ground and 5V rails) and use analogRead to determine the joystick position, map/convert that to a servo position however you want, and then use the Servo library to putput the corresponding servo PWM pulse.

Of course you could use an ordinary hobby RC system, and control it via radio using perfectly ordinary off-the-shelf systems.

The servo "knob" code example in the arduino IDE should be of interest for basic joystick learning.

Hi WelshGuy,

I agree with the them all.

Most of these would work: http://www.jameco.com/webapp/wcs/stores/servlet/StoreCatalogDrillDownView?langId=-1&storeId=10001&catalogId=10001&search_type=jamecoall&freeText=Joystick

I wouldn't make the project any more complicated than that. The USB approach is overkill for what you're trying to do. Besides... You can buy some new components!

Pat.

I agree.

We use this one wired exactly as shown on that link. Connect the Y axis to another analog pin, and double up the code in the knob skecth for say potpin2 and attach say servo2 on another pin and you have x and y servo control.

That particular joystick has a switch- push the button in to fire a rocket or whatever: you can attach that using this as a guide.

I just ordered some of these for tinkering. They appear to have a switch button on the side also.

http://www.ebay.com/itm/3-X-New-Handle-Joystick-3D-Sony-Playstation2-PS2-PS-2-10V-/230803703512?pt=LH_DefaultDomain_0&hash=item35bcf906d8

Firstly, thank you so much for all your prompt replies :smiley:

I had a look at the thumbsticks you mentioned and I agree that it does seem like a much simpler process. My only concern is that the system is being designed for use by a large number of children, and having a solid, large, grippable joystick would both a) make it look more impressive and b) be a bit easier for smaller kids to use.

Does anything exist that has the ease of use of the thumbsticks but in a larger design?

Thanks!

Well there are these but at e125 they're just a leeeeetle bit pricey look you.

WelshGuy:
Does anything exist that has the ease of use of the thumbsticks but in a larger design?

Perhaps you could attach a larger handle to the input, so that it looked a bit more like the sort of thing you see on a radio control transmitter?

PeterH:
Perhaps you could attach a larger handle to the input, so that it looked a bit more like the sort of thing you see on a radio control transmitter?

That's a good point- if you take the thumb thingy off mine you end up with what zoomkat linked to, and you could fashion a longer handle to slide over the prong.

But I'd be careful of any damage that the extra leverage could cause, especially in the heat of a game. Perhaps that's why the bigger ones are more expensive: they need to withstand higher moments inside.

I also found this but it has limit switches not pots.

JimboZA:
I also found this but it has limit switches not pots.

Hmm that could work Jimbo, thanks!

I don't need it for a game, it's for a museum-style exhibit that will control the pitch rotation of a wing section in a wind tunnel. I guess I don't technically need variable control...

Ah ok, so a basic l-r-u-d thing could suffice?

That big joystick from RS looks like a gear-lever from an 18-wheeler tho: there must be something smaller yet robust and not costing over e100 a pop

PS... with limit switches I guess you could just read them like in this sketch and when a switch is closed have a servo.write command to one position, and to another when it's open. Eminently doable with an if testing the buttons' states.

Thinking it over I do think variable control would be a bonus though...

Essentially I have a wing section with a rod running through it spanwise. This needs to rotate (ie pitch the wing up, return it to horizontal and then pitch down then return to horizontal). A servo mechanism currently exists to rotate the rod, but with no control. If I had variable control I guess I could code something that would let me hold the joystick at a given position in order to command a certain angle of rotation. If it was limit switches I guess it would be a little more complicated.

I only need a single-axis of control, providing rotation +-60 degrees.

Arcade joysticks are more robust than the typical home game versions. Looks like some are fairly affordable.

https://www.google.com/search?q=arcade+joystick&num=100&hl=en&lr=&tbo=u&as_qdr=all&source=univ&tbm=shop&sa=X&ei=xSX_UNaNNO-D0QGhqIDYAw&ved=0CE8Qsxg&biw=1173&bih=642

This company has a bunch of Arcade joysticks:

I think they are all switch based, not analog.

Ok last question... in your opinions, how easy would it be to mod one of the thumbsticks to give it a bigger handle? I think the analogue control would be best, and you've given me some great diagrams and tips to go on so I think the thumbstick is the way I'll go.

Actually, I lied. This is the last question: Which arduino should I get? :slight_smile:

how easy would it be to mod one of the thumbsticks to give it a bigger handle?

A stick and hot glue.

mod one of the thumbsticks to give it a bigger handle

I'd be concerned about mechanical damage though... extra leverage + exuberant kids = bad combination, Taffy