Loading...
Pages: [1]   Go Down
Author Topic: Joystick shield help  (Read 241 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
Tesla Member
***
Karma: 89
Posts: 6396
-
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

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
Edison Member
*
Karma: 29
Posts: 1576
"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

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

0
Online Online
Tesla Member
***
Karma: 50
Posts: 6553
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

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Johannesburg UTC+2
Offline Offline
Edison Member
*
Karma: 34
Posts: 1705
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

IT Crowd:
Roy... "Have you tried turning it off and on again?"
Moss.. "Have you tried forcing an unexpected reboot?"

Queens, New York
Offline Offline
Edison Member
*
Karma: 29
Posts: 1576
"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

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

Johannesburg UTC+2
Offline Offline
Edison Member
*
Karma: 34
Posts: 1705
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

IT Crowd:
Roy... "Have you tried turning it off and on again?"
Moss.. "Have you tried forcing an unexpected reboot?"

Queens, New York
Offline Offline
Edison Member
*
Karma: 29
Posts: 1576
"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

UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino

Arduino Tutorials, coming soon.

"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown

UK
Offline Offline
Tesla Member
***
Karma: 89
Posts: 6396
-
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

Pages: [1]   Go Up
Print
 
Jump to: