Little struggle with VarSpeedServo (and she is winning so far)

Hi all :slight_smile: Glad to be here!.

I am a thousand miles away from being a regular Arduino programmer, but this short and easy piece of code is taking my sleep away.

And if you don't mind, let's go straight to the point.

--- I use an Arduino UNO board on Windows7 with Arduino 1.6.10.

--- I want to make move a servo controlling its rotating speed but keeping its torque.

--- I have just found the VarSpeedServo librarie.

--- The VarSpeedServo librarie has been installed from the .zip file with Arduino 1.6.10 in C:/Users/My name/My Documents/Arduino/libraries. Skecthes are kept in C:/Users/My name/My Documents/Arduino/

--- VarSpeedServo.cpp file has been modified, changing 'Wprogram.h' for 'Arduino.h'.

--- I have read everything on VarSpeedServo librarie here and at Adafruit's.

--- I have found this piece of code ( Sample Code - one servo moving, wait for first movement to finish, then execute another movement ) here ( GitHub - netlabtoolkit/VarSpeedServo: Arduino library for servos that extends the standard servo.h library with the ability to set speed, and wait for position to complete ).

--- This piece of code is cited at some threads on this forum, but unfortunately can't find a solution yet.

--- On my side, in the functions myservo.write(), I have changed the hard coded values (0, 180, etc.) for 'int' variables like pos1, pos2, vel1 y vel2 as constants.

--- I have tried to compile it once and again to no avail. So, in my quest to find out what's going wrong, I am compiling it by parts.

--- And so far, I only get to compile correctly this code:

#include <VarSpeedServo.h>;


VarSpeedServo myservo;    

const int servoPin = 9; 
const int pos1 = 0;
const int pos2 = 180;
const int vel1 = 100;
const int vel2 = 30;


void setup() {
  myservo.attach(servoPin);  
  //myservo.write(pos1,vel1,true);
} 

void loop() {
  //myservo.write(pos2,vel1,true); 
  //myservo.write(pos1,vel2,true);

delay(1000);
}

--- But as soon as I take away the bars // before the myservo.write() function at:

void setup():
myservo.write(pos1,vel1,true); and

void loop():
myservo.write(pos2,vel1,true);
myservo.write(pos1,vel2,true);

and try to compile, I get an error like the one in the attached file, ending with this:

...

exit status 1 no matching function for call to 'VarSpeedServo::write(const int&, const int&, bool)'

I will truly thank any help from you.

Engadin.

I will truly thank any help from you.

There is more to the message than that. That part is usually followed by a list of overloads of the function, so you can choose the right one.

The class has three overloads:

  void write(int value);             // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
  void write(int value, uint8_t speed); // Move to given position at reduced speed.
          // speed=0 is identical to write, speed=1 slowest and speed=255 fastest.
          // On the RC-Servos tested, speeds differences above 127 can't be noticed,
          // because of the mechanical limits of the servo.
void write(int value, uint8_t speed, bool wait); // wait parameter causes call to block until move completes

You'll notice that none of the overloads expects const values or arguments.

So, the first thing to do is remove the const keyword from the variables you are using.

The second thing to do is to notice that the second argument, if used, is a byte, not an int.

Aside from the extra ';' on the #include of VarSpeedServo.h it compiles without changes or errors on Arduino 1.8.2. Might be time to update.

If you had to change WProgram.h to Arduino.h you probably don't have the latest version of VarSpeedServo:

:o You are truly quick responding, PaulS.

I'll put my hands on your solution as soon as I'm back home.

You made my day, Clint's way. Thank you so much. :slight_smile:

Yes, the full error list is somewhat frightening.

Engadin.

johnwasser:
Aside from the extra ';' on the #include of VarSpeedServo.h it compiles without changes or errors on Arduino 1.8.2. Might be time to update.

If you had to change WProgram.h to Arduino.h you probably don't have the latest version of VarSpeedServo:
GitHub - netlabtoolkit/VarSpeedServo: Arduino library for servos that extends the standard servo.h library with the ability to set speed, and wait for position to complete

Ouch! Yes, I am using a bit outdated version of arduino because it's advised so in the arduino brushing up course at programmingelectronics.com I am taking these days. OTOH, the librarie's date is March, 23, 2015.

So, I guess an arduino updating is something I'll have to decide on in the coming days in order to avoid this sort of sticks in my wheels. I really don't need any more, because as an almost newbie in this matter I am a true expert in that, as you can see. :smiley:

Many thanks johnwasser.

Engadin.