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