Search Code
About Servo

First published 16 Nov 2009, with 4 revisions since.
Last update: 10 Feb 2010.
View history

Last change message: N/A

Related to

Servo_HelloWorld
Example to sweep a servo through its range
tag helloworld, PwmOut, Servo

WebTrafficMonitor
Example of a simple website hits/signup traffic monitor to drive a display (e.g. servo or panel meter) and indicator (e.g. bell, solenoid) based on responses from a webserver
tag ethernet, http, monitor, webserver


Pinewood_Derby_Timer
This is the end gate portion of a pinewood derby timer that uses an mbed. It communicates via HTTP to a web server that is doing the racer control and ...
tag derby, pinewood

EtonBreadboard1
Firmware for Eton breadboard


EtonBreadboard_091
Modification in routine to select substance


AVC_20110423
The software I used to run my Sparkfun AVC 2011 entry, a 1:10 scale RC truck called \"Data Bus\". This is the final revision of the code as-run on April ...
tag avc, robomagellan

MyFinalDerbot
Work for University.
tag Derby University, Kevin

ServoCamV1
This is the ServoCam Project, as shown here: http://youtu.be/riiqyXnckR4
tag mbed, ServoCam, servos, uart samera

TeaBasic
This will provide you with a nice little tea maker, which will dip your teabag in and take it out after a specified amount of time. You can set how ...
tag beginner, buttons, dipping, first, LCD, maker, matic, mbed, o, Servo, tea, wonderful

TeabagControlDevice
An updated and more polished version of the earlier TeaBasic. This is now finished and works like a treat.
tag control, device, maker, tea, teabag

Sorbonne2
Sorbonne 2 firmware
tag Sorbonne2

Exp5_RCservo
Exp5_RCservo
tag Exp5_RCservo

Exp5_ForceFeedback
Exp5_ForceFeedback
tag Exp5_ForceFeedback

GSL_09-HttpServer-RPC-Funcs_Servos
Code to demonstrate how to map 2 RPC functions to command 2 servo motors via REST HTTP Get request. Pretty useful to control a webcam PAN and TILT position when ...
tag camera, geeksessionlab, get, http, motor, pan, position, rest, rpc, Servo, tilt, webinterface

banda
El de mi banda transportadora + FPGA

Arm_Serial_Coordinates
Takes in serial coordinates (in mm) and moves servos in Lynxmotion AL5 arm accordingly.
tag RoboArm

rosserial_mbed
This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.
tag ROS

Auto2
FET10 UNIMOG
tag FET10, UNIMOG

Servo
tag library, Servo

LineTracer_test
ライントレーサーのテストプログラムです。 コンパイルのみ 動作未チェック

RFID_doorlock
It is a door opener with mbed and Felica(RFID).
tag RFID

Import this program

Servo

Published 10 Feb 2010, by   user Simon Ford   tag library, Servo
Embed: (wiki syntax)

« Back to documentation index

You are viewing an out of date revision of Servo! View latest revision

Show/hide line numbers Servo.h Source File

Servo.h

00001 /* mbed R/C Servo
00002  * Copyright (c) 2007-2009 sford, cstyles
00003  * Released under the MIT License: http://mbed.org/license/mit
00004  */
00005   
00006 #ifndef MBED_SERVO_H
00007 #define MBED_SERVO_H
00008 
00009 #include "mbed.h"
00010 
00011 /* Class: Servo
00012  *  Abstraction on top of PwmOut to control the position of a servo motor
00013  *
00014  * Example:
00015  * > // Continuously sweep the servo through it's full range
00016  * > #include "mbed.h"
00017  * > #include "Servo.h"
00018  * >
00019  * > Servo myservo(p21);
00020  * >
00021  * > int main() {
00022  * >     while(1) {
00023  * >         for(int i=0; i<100; i++) {
00024  * >             myservo = i/100.0;
00025  * >             wait(0.01);
00026  * >         }
00027  * >         for(int i=100; i>0; i--) {
00028  * >             myservo = i/100.0;
00029  * >             wait(0.01);
00030  * >         }
00031  * >     }
00032  * > }
00033  */
00034 class Servo {
00035 
00036 public:
00037     /* Constructor: Servo
00038      *  Create a servo object connected to the specified PwmOut pin
00039      *
00040      * Variables:
00041      *  pin - PwmOut pin to connect to 
00042      */
00043     Servo(PinName pin);
00044     
00045     /* Function: write
00046      *  Set the servo position, normalised to it's full range
00047      *
00048      * Variables:
00049      *  percent - A normalised number 0.0-1.0 to represent the full range.
00050      */
00051     void write(float percent);
00052     
00053     /* Function: read
00054      *  Read the servo motors current position
00055      *
00056      * Variables:
00057      *  returns - A normalised number 0.0-1.0  representing the full range.
00058      */
00059     float read();
00060     
00061     /* Function: position
00062      *  Set the servo position
00063      *
00064      * Variables:
00065      *  degrees - Servo position in degrees
00066      */
00067     void position(float degrees);
00068     
00069     /* Function: calibrate
00070      *  Allows calibration of the range and angles for a particular servo
00071      *
00072      *
00073      * Variables:
00074      *  range - Pulsewidth range from center (1.5ms) to maximum/minimum position in seconds
00075      *  degrees - Angle from centre to maximum/minimum position in degrees
00076      */
00077     void calibrate(float range = 0.0005, float degrees = 45.0); 
00078         
00079     /* Function: operator=
00080      *  Shorthand for the write and read functions
00081      */
00082     Servo& operator= (float percent);
00083     Servo& operator= (Servo& rhs);
00084     operator float();
00085 
00086 protected:
00087     PwmOut _pwm;
00088     float _range;
00089     float _degrees;
00090     float _p;
00091 };
00092 
00093 
00094 
00095 #endif