Thumb Stick 2 servos Sweep

I copied this code from a website and changed some of the values. However I can not make the servo move 175 degrees in both directions. I can use 360 which will only move in a complete circle and move back after I let go of the thumb stick or 180 degrees which will split into 90 degree rotational travel left and right. Please advise I'm trying to get 180 degree movement range in both direction.

CODE:

#include <Servo.h>

const int servo1 = 3; // first servo
const int servo2 = 10; // second servo
const int joyH = 3; // L/R Parallax Thumbstick
const int joyV = 4; // U/D Parallax Thumbstick

int servoVal; // variable to read the value from the analog pin

Servo myservo1; // create servo object to control a servo
Servo myservo2; // create servo object to control a servo

void setup() {

// Servo
myservo1.attach(servo1); // attaches the servo
myservo2.attach(servo2); // attaches the servo

// Inizialize Serial
Serial.begin(9600);
}

void loop(){

// Display Joystick values using the serial monitor
outputJoystick();

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

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

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

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

delay(15); // waits for the servo to get there

}

/**

  • Display joystick values
    */
    void outputJoystick(){

Serial.print(analogRead(joyH));
Serial.print ("---");
Serial.print(analogRead(joyV));
Serial.println ("----------------");
}

It sounds like you're using continuous rotation servos. The normal sweep code won't work as expected with CR servos.

I posted some joystick servo code here.

If you use the position control code, it should behave like you're using the speed control code.

You can use the joystick to tell the servos how fast to move but you can't directly command which position the servos should take since CR servos don't have position feedback.

scorpios1151982:
I can use 360 which will only move in a complete circle

The above quote is what makes me think you're using a CR servo but the rest of your post doesn't make this so clear. If the servo returns to its original position, then it doesn't sound like you have a CR servo.

Can you provide a link to the servos you're using?

@scorpios1151982, do not cross-post. Other post removed.