Pages: [1]   Go Down
Author Topic: Joystick shield help  (Read 610 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11179
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you're clear about what you want it to do, then it can be done with code.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2934
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 17, 2013, 11:09:13 pm by HazardsMind » Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Retired from Arduino.
PMs are set to ignore all.

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2934
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Faraday Member
**
Karma: 60
Posts: 3242
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Retired from Arduino.
PMs are set to ignore all.

Queens, New York
Offline Offline
Faraday Member
**
Karma: 65
Posts: 2934
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im sure some place does make them without a spring, but where exactly, I dont know. I never needed to look for one.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11179
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: