« Servo

A library for controlling a Radio Control (R/C) model Servo.

R/C Model Servo

헬로 월드!

Import program

00001 // Hello World to sweep a servo through its full range
00003 #include "mbed.h"
00004 #include "Servo.h"
00006 Servo myservo(p21);
00008 int main() {    
00009     for(float p=0; p<1.0; p += 0.1) {
00010         myservo = p;
00011         wait(0.2);
00012     }
00013 }


Import library

Public Member Functions

  Servo (PinName pin)
  Create a servo object connected to the specified PwmOut pin.
void  write (float percent)
  Set the servo position, normalised to it's full range.
float  read ()
  Read the servo motors current position.
void  position (float degrees)
  Set the servo position.
void  calibrate (float range=0.0005, float degrees=45.0)
  Allows calibration of the range and angles for a particular servo.
Servo operator= (float percent)
  Shorthand for the write and read functions.

This library controls a standard R/C model servo using a PwmOut signal, and provides control of the servo between min and max by setting it to 0.0 - 1.0.

As all servos respond differently, you can also use the calibrate function the range, so 0.0 - 1.0 is the maximum range of the servo.


All wikipages