han back
/
CLEO_SERVO
SMART CLEO Servo
main.cpp
- Committer:
- SMART_CLEO
- Date:
- 2017-09-28
- Revision:
- 0:751077e5fa50
File content as of revision 0:751077e5fa50:
#include "mbed.h" PinName pin_SERVO = PA_5; PwmOut Servo(pin_SERVO); void Servo_angle(int16_t angle); int main() { Servo.period_ms(20); while(1) { // 0 ~ 180 for(int i=0; i<=180; i++) { Servo_angle(i); wait(0.02); } // 180 ~ 0 for(int i=180; i>=0; i--) { Servo_angle(i); wait(0.02); } } } void Servo_angle(int16_t angle) { int16_t Angle = 600 + (angle * 10); Servo.pulsewidth_us(Angle); }