Passing A Servo.h Object as a Parameter to a Func.

Happy 20 Double Toothpicks!

I'm sure this may be a fairly trivial C question, however I typically dabble in the world of ruby/python so C is a beast of its own right for me...to the the million dollar question:

How would one pass a previously instantiated servo object (i.e. "panservo" and "tiltservo" noted below) as a parameter to a function? I'm not sure how to set the type for the first param in the "motor_choice()" function listed below.

If I create a Servo object like this:

#include Servo.h
Servo panservo;
Servo tiltservo;

void setup() {
  panservo.attach(9);   // Setup Pan Servo ;)
  tiltservo.attach(10); // Setup Tilt Servo ;)
}

void motor_choice(servo_obj, int speed) { // THE 1ST PARAM IS THE ISSUE
  // Do Stuff
}

void loop() {
  motor_choice(panservo, -4);
  motor_choice(tiltservo, 4);
}

Any help would be greatly appreciated!

Regards!!! :smiley:

void motor_choice(Servo &theServo, int speed)
{
   theServo.writeMicroseconds(speed);
}

Perfect. Thank you so much!