Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed ssWi
servo.cpp
00001 #include "servo.hpp" 00002 00003 00004 Servo::Servo (PinName pwm, float min, float max, float center): _pwm(pwm) 00005 { 00006 _pwm.period(0.02); 00007 _min = min; 00008 _max = max; 00009 _center = center; 00010 *this = 0.5; 00011 } 00012 00013 Servo &Servo::operator= (float angle) 00014 { 00015 if (angle>1.0) 00016 angle = 1.0; 00017 else 00018 if (angle<-1.0) 00019 angle = -1.0; 00020 _pwm.pulsewidth(_center+((_max-_min)*(angle/2.0))); 00021 return *this; 00022 } 00023 00024 Servo::operator float() 00025 { 00026 return _pwm.read(); 00027 }
Generated on Tue Jul 19 2022 13:36:11 by
1.7.2