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.
Diff: PwmServo.cpp
- Revision:
- 0:916047fa0d8b
- Child:
- 5:8223f5a154e2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PwmServo.cpp Wed Sep 17 15:17:24 2014 +0000 @@ -0,0 +1,30 @@ +/* + + Controller firmware for CaitSithDanger + + Kyoto-Densou-An 2014 + + Author : yishii +*/ +#include <mbed.h> +#include <PwmServo.h> + +PwmServo::PwmServo(PinName pin) +{ + pwm = new PwmOut(pin); + pwm->period_ms(PWM_CONTROL_PERIOD); + pwm->write(0.20); +} + +PwmServo::~PwmServo() +{ + delete pwm; +} + +void PwmServo::setAngle(float angle) +{ + //pwm->pulsewidth(((angle/180) + 1) / 1000); + pwm->pulsewidth_us((angle*2000)/180+500);//This values correspond to SG90. +} + +