Offline
Newbie
Karma: 0
Posts: 2
|
 |
« on: February 17, 2013, 09:24:03 pm » |
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
Tesla Member
Karma: 89
Posts: 6396
-
|
 |
« Reply #1 on: February 17, 2013, 09:39:23 pm » |
If you're clear about what you want it to do, then it can be done with code.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 2
|
 |
« Reply #2 on: February 17, 2013, 10:02:38 pm » |
What would the code be? How would i do it?
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Offline
Edison Member
Karma: 29
Posts: 1576
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #3 on: February 17, 2013, 10:38:31 pm » |
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
Tesla Member
Karma: 50
Posts: 6553
Arduino rocks
|
 |
« Reply #4 on: February 17, 2013, 11:10:27 pm » |
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
|
|
|
|
|
Johannesburg UTC+2
Offline
Edison Member
Karma: 34
Posts: 1705
|
 |
« Reply #5 on: February 17, 2013, 11:16:52 pm » |
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
Edison Member
Karma: 29
Posts: 1576
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #6 on: February 17, 2013, 11:20:35 pm » |
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
Edison Member
Karma: 34
Posts: 1705
|
 |
« Reply #7 on: February 17, 2013, 11:26:11 pm » |
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
Edison Member
Karma: 29
Posts: 1576
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #8 on: February 17, 2013, 11:31:35 pm » |
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
Tesla Member
Karma: 89
Posts: 6396
-
|
 |
« Reply #9 on: February 18, 2013, 08:31:42 am » |
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
|
|
|
|
|
|