5servo control

hello friends I need your help for a code , I'm doing a project of a robotic arm with five servo and want to control with 3 joysticks , and I need that when you release the joystick the servos do not return to their position , I am working with Arduino Uno. Please Help me

In that case start by reading the "How to use this forum - please read" thread. Its there
for a reason.

  • especially point 10

and I need that when you release the joystick the servos do not return to their position

So, modify the joystick to remove the return springs.

Otherwise, you need to determine when moving the joystick matters and when it doesn't. And, that is not trivial.

reynieraxel, I believe you are referring to "non follow-up" control where you move the joystick forwards to make the robotic arm move forwards and bring the joystick back to center to stop it. In other words, joysticks tell the robotic arm which direction to go but not to a set position. Is this correct?

If so, there is a simple way to implement that type of control.
In pseudocode:

  1. Read the analog joystick values,
  2. Map those values to some range such as -1 to +1, and
  3. Add that mapped value to the previous servo control signal for each loop.

Yes Space Monkey
This is the code that im trying to modify

#include <Servo.h>

Servo myservo_pan;
Servo myservo_tilt;
int servoVal;
int servoVal2;

const int buttonPin1 = 3;
const int buttonPin3 = 4;

//const int joyH = 3; // L/R Parallax Thumbstick
//const int joyV = 4; // U/D Parallax Thumbstick

// Your two servos use digital pins as well.

const int servo_pan_Pin = 9;
const int servo_tilt_Pin = 10;

// We create states for each of the 4 axis.

int button1State = 0;
int button3State = 0;

// Initial values for the servos. 90 degrees for both. Centered.

int pan;
int tilt;

void setup()
{

// Set our joystick 4 axis pins to input modes.

//pinMode(buttonPin1, INPUT);
//pinMode(buttonPin3, INPUT);

// Attach your two servos to the pins.

myservo_pan.attach(servo_pan_Pin); // attaches the servo
myservo_tilt.attach(servo_tilt_Pin);

// myservo_pan.attach(servo_pan_Pin);
//myservo_tilt.attach(servo_tilt_Pin);

// Set the servos to their “home” position.

myservo_tilt.write(tilt);
myservo_pan.write(pan);
Serial.begin(9600);
}

void loop()
{
// Read your 4 axis for changes.

//button1State = digitalRead(buttonPin1);
//button3State = digitalRead(buttonPin3);

// If one of the axis is used, increment or decrement.

//if (button1State == HIGH) { pan++; } //up
//if (button3State == HIGH) { tilt++; } //left

servoVal = analogRead(buttonPin1);
// servoVal = map(servoVal, 0, 1023, 0, 180); // scale it to use it with the servo (result between 0 and 180)
servoVal = if ( servoVal >= 90 ) ( servoVal = 90 );
//myservo_pan.write(servoVal); // sets the servo position according to the scaled value

// Read the horizontal joystick value (value between 0 and 1023)
servoVal2 = analogRead(buttonPin3);
// servoVal = map(servoVal, 0, 1023, 70, 180); // scale it to use it with the servo (result between 70 and 180)

// myservo_tilt.write(servoVal); // sets the servo position according to the scaled value

if ( servoVal >= 90 ) { servoVal = 90; }
if ( servoVal2 <= 20 ) { servoVal2 = 20; }
//if ( servoVal >= 90 ) { servoVal = 90; }
//if ( servoVal2 <= 20 ) { servoVal2 = 20; }
// Finally write to the servos the degree to set them to.

myservo_tilt.write(servoVal);
myservo_pan.write(servoVal2);

}

SpaceJockey:
reynieraxel, I believe you are referring to "non follow-up" control where you move the joystick forwards to make the robotic arm move forwards and bring the joystick back to center to stop it. In other words, joysticks tell the robotic arm which direction to go but not to a set position. Is this correct?

If so, there is a simple way to implement that type of control.
In pseudocode:

  1. Read the analog joystick values,
  2. Map those values to some range such as -1 to +1, and
  3. Add that mapped value to the previous servo control signal for each loop.

hello friends I need your help for a code , I'm doing a project of a robotic arm with five servo and want to control with 3 joysticks , and I need that when you release the joystick the servos do not return to their position , I am working with Arduino Uno. Please Help me

#7 below for how to post your code. As previously mentioned, you might disable the return springs in the joystick In the past I made a program in another programming language that used the stick button control when the stick was active. The pot read/servo move code was only entered when the button was pushed. When the button was released, the control loop was exited. Another approach might be using the stick to control the direction and speed of servo movement, but not absolute servo position.

http://forum.arduino.cc/index.php/topic,148850.0.html

SpaceJockey:
reynieraxel, I believe you are referring to "non follow-up" control where you move the joystick forwards to make the robotic arm move forwards and bring the joystick back to center to stop it. In other words, joysticks tell the robotic arm which direction to go but not to a set position. Is this correct?

If so, there is a simple way to implement that type of control.
In pseudocode:

  1. Read the analog joystick values,
  2. Map those values to some range such as -1 to +1, and
  3. Add that mapped value to the previous servo control signal for each loop.

That's good thinking: I might try something like that with my meArm (see blog), thanks for the idea.