Chen Huan
/
Final_DongGanPingTai
Tsinghua Icenter ChenHuan
servo/Servo.h
- Committer:
- heroistired
- Date:
- 2017-03-16
- Revision:
- 0:9b8df4f9b792
File content as of revision 0:9b8df4f9b792:
#ifndef __SERVO_H #define __SERVO_H #include "mbed.h" //舵机类 /*class Servo { public: Servo(PinName pin); void SetDegree(float degree); private: PwmOut _pin; };*/ class Servo { public: Servo(PinName pin) : _pin(pin) { _pin = 0; } void SetDegree(float degree) { float duty = (degree/180.0*2+0.5)/20; _pin.period_ms(20); _pin.write(duty); } private: PwmOut _pin; }; #endif