Getting a Strange Error code

im new to coding with arduino but im use to coding with php im trying to compile this code but for some strange reason im getting no matching function for call to ‘Servo::write(int&, int, int, int, int)’ on two parts of the code

myservoxAxis.write(xReading, 0, 1023, 0, 360);
myservoyAxis.write(yReading, 0, 1023, 0, 360);

the Servo’s name’s has been declared at the top as all the forms show but getting it to compile is tricky…

Full Code Bellow

#include <Servo.h>

Servo myservoxAxis;
Servo myservoyAxis;  // create servo object to control a servo
int xAxis = 0; // analog pin used to connect the potentiometer
int yAxis = 1;
int range = 360;
int center = range / 2;
int threshold = range / 4;

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

void setup() {
  myservoxAxis.attach(8);  // attaches the servo on pin 9 to the servo object
  myservoyAxis.attach(9);
}

void loop() {
  int xReading = readAxis(xAxis);
  int yReading = readAxis(yAxis);

  //value = analogRead(tiltpin); // reads the value of the potentiometer (value between 0 and 1023)
  //val = analogRead(panpin);


  //value = map(value, 0, 1023, 0, 360); // scale it to use it with the servo (value between 0 and 180)
  //val = map(val, 0, 1023, 0, 360);

  myservoxAxis.write(xReading, 0, 1023, 0, 360);                // sets the servo position according to the scaled value
  myservoyAxis.write(yReading, 0, 1023, 0, 360);
}


int readAxis(int thisAxis) {
  // read the analog input:
  int reading = analogRead(thisAxis);

  // map the reading from the analog input range to the output range:
  reading = map(reading, 0, 1023, 0, range);

  // if the output reading is outside from the
  // rest position threshold,  use it:
  int distance = reading - center;

  if (abs(distance) < threshold) {
    distance = 0;
  }

  // return the distance for this axis:
  return distance;
}

Hope you guys can help me learn a thing or two, Thanks in Advance AndyPudding

The error message tells you exactly what is wrong. The write() function expects an int but you've given it five ints. It looks like you've just copied and pasted the arguments from the map function that is commented out above it. You need to work out the single value you want for the position and give that to write().

Unfortunately, there are many Servo libraries that are named Servo and you provided no link to the specific library that is in use.

If you are using the Arduino Servo library, the documentation says that write takes one parameter, an angle from 0 to 180 degrees. You should not be providing five parameters unless you are using a different library. Perhaps you intended

myservoxAxis.write(map(xReading, 0, 1023, 0, 180));
myservoyAxis.write(map(yReading, 0, 1023, 0, 180));

Instructions for Posting Code Below

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.
  5. Please provide links to any libraries that are used
    (look for statements in your code that look like #include ). Many libraries
    are named the same but have different contents.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!