I am developing a project in which I must rotate a servomotor. But my idea is to pass all the values in a function parameters.
I want to pass the object as parameter of the servo in the function "moveServo".
Agradesco any contribution. ![]()
#include <Servo.h>
Servo myservo;
void setup() {
myservo.attach(9);
}
moveServo(int servo, int grade, int time) {
int n;
for(n=0;n<=1;n++) {
servo.write(grade);
delay(time);
}
}
void loop() {
moveServo(myservo,90, 1000);
}
This is error:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
code_2:9: error: ISO C++ forbids declaration of 'moveServo' with no type
code_2.ino: In function 'int moveServo(int, int, int)':
code_2:13: error: request for member 'write' in 'servo', which is of non-class type 'int'
code_2.ino: In function 'void loop()':
code_2:19: error: cannot convert 'Servo' to 'int' for argument '1' to 'int moveServo(int, int, int)'