Go Down

Topic: Joystick shield help (Read 806 times) previous topic - next topic

SciolyGuy

So im still a noob with the arduino but i need help for a robot arm im making. I got the sparkfun joystick shield and i got it to control my servo and all but what i need it to do islets say i move the stick to the left then back to the center- i need the servo to stay left. Can that be done with code? Do i have to mod the servo?

PeterH

If you're clear about what you want it to do, then it can be done with code.
I only provide help via the forum - please do not contact me for private consultancy.

SciolyGuy

What would the code be? How would i do it?

HazardsMind

#3
Feb 18, 2013, 04:38 am Last Edit: Feb 18, 2013, 05:09 am by HazardsMind Reason: 1
Well what I would do is use a joystick and a button. Joystick to move the servo, and the button to lock the position. I would set the button up as a latch, so press it once, it stores the set position, press again clear it.

Add: Or what you can do is, have it so that in order to move the servo, you have to press and hold the button. You let go of the button, and the position stays.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

zoomkat

You could use a button such that the current pot position servo value is only sent to the servo if the button is pressed. When the button is released the stick could be allowed to return to the neutral position. Note that this setup will allow the servo to jump when the button is pressed again and the pot is not in the previous position.

An alternative approach would have the current pot position to determine weather the servo control value is to increase or decrease from the current position, and the magnatude of the incremental value changes. A pot position close to the neutral position value would have small incremental change values, and pot positions far from the neutral position would have large changes. The joystick would control the servo rotation direction and the speed of the rotation in that direction.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

JimboZA

This is good stuff guys- I've been wondering this too.

On the other hand, are there any joysticks which don't self-centre?
Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

HazardsMind

Quote
On the other hand, are there any joysticks which don't self-centre?

Yes, in fact without a spring, the joystick will stay in place, provided it is not too heavy and won't move when tilted.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

JimboZA

Quote
without a spring, the joystick will stay in place


Yep, but what I meant was, do "they" make any like that or do "we" have to hack one?
Roy from ITCrowd: Have you tried turning it off an on again?
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

HazardsMind

Im sure some place does make them without a spring, but where exactly, I dont know. I never needed to look for one.
My GitHub:
https://github.com/AndrewMascolo?tab=repositories

PeterH


What would the code be? How would i do it?


Firstly, write a sketch that reads the joystick position and just prints it out, to prove you can. And write another sketch that just moves the servo through a fixed sequence of positions, to prove you can.

Make sure you have a clear and complete understanding of what behaviour you want to provide. For example, in your description you have described how the output moves to the left when the joystick moves left, but does not move back to center when the joystick moves back.What else happens? Is there some way to move the output back to center? Is there any way to move it further to the left? The details matter.

Finally, write your sketch that reads the joystick position and uses it to control the servo position, using the algorithm you have described above. If you want some help on this last bit, then you will need to explain to us what the behaviour is that you're trying to provide.
I only provide help via the forum - please do not contact me for private consultancy.

Go Up