libkovan  1
The kovan standard library
Servos

Classes

class  Servo
 Encapsulates the concept of a servo motor. More...
 

Functions

VF EXPORT_SYM void enable_servo (int port)
 
VF EXPORT_SYM void disable_servo (int port)
 
VF EXPORT_SYM void enable_servos ()
 
VF EXPORT_SYM void disable_servos ()
 
VF EXPORT_SYM void set_servo_enabled (int port, int enabled)
 
VF EXPORT_SYM int get_servo_enabled (int port)
 
VF EXPORT_SYM int get_servo_position (int servo)
 
VF EXPORT_SYM void set_servo_position (int servo, int position)
 

Detailed Description

Function Documentation

VF EXPORT_SYM void disable_servo ( int  port)
VF EXPORT_SYM void disable_servos ( )
VF EXPORT_SYM void enable_servo ( int  port)
VF EXPORT_SYM void enable_servos ( )
VF EXPORT_SYM int get_servo_enabled ( int  port)
VF EXPORT_SYM int get_servo_position ( int  servo)
Parameters
servoThe port of the servo
Returns
The servo's position as a 10 bit integer (which is an integer between 0 and 1024)
Note
Thie method will return the last sent position, not the currently set position.
For example, imagine the following:
  1. set_servo_position(0, 700);
  2. ... Some time passes ...
  3. set_servo_position(0, 300);
  4. get_servo_position(0);
get_servo_position(int) will return 700 rather than 300, because 300 hasn't been sent to the servo yet.
VF EXPORT_SYM void set_servo_enabled ( int  port,
int  enabled 
)
VF EXPORT_SYM void set_servo_position ( int  servo,
int  position 
)
Parameters
servoThe port of the servo
positionThe new servo position, between 0 and 1023
Note
Even though the servos have a theoretical range between 0 and 1024, the actual range is often less. Setting the servo to a position that it cannot physically reach will cause the servo to audibly strain and will consume battery very quickly.