Matthias Grob
/
FlyBed2
My fully self designed first stable working Quadrocopter Software.
Servo_PWM/Servo_PWM.h@10:14390c90c3f5, 2015-08-31 (annotated)
- Committer:
- maetugr
- Date:
- Mon Aug 31 20:20:50 2015 +0000
- Revision:
- 10:14390c90c3f5
- Parent:
- 5:06e978fd147a
before changing to MPU9250
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 5:06e978fd147a | 1 | // by MaEtUgR |
maetugr | 5:06e978fd147a | 2 | |
maetugr | 5:06e978fd147a | 3 | #ifndef SERVO_PWM_H |
maetugr | 5:06e978fd147a | 4 | #define SERVO_PWM_H |
maetugr | 5:06e978fd147a | 5 | |
maetugr | 5:06e978fd147a | 6 | #include "mbed.h" |
maetugr | 5:06e978fd147a | 7 | |
maetugr | 5:06e978fd147a | 8 | /** Class to control a servo by using PWM |
maetugr | 5:06e978fd147a | 9 | */ |
maetugr | 5:06e978fd147a | 10 | |
maetugr | 5:06e978fd147a | 11 | class Servo_PWM { |
maetugr | 5:06e978fd147a | 12 | |
maetugr | 5:06e978fd147a | 13 | public: |
maetugr | 5:06e978fd147a | 14 | /** Create a new Servo object on any PWM pin |
maetugr | 5:06e978fd147a | 15 | * |
maetugr | 5:06e978fd147a | 16 | * @param Pin Pin on mbed to connect servo to |
maetugr | 5:06e978fd147a | 17 | */ |
maetugr | 5:06e978fd147a | 18 | Servo_PWM(PinName Pin, int frequency); |
maetugr | 5:06e978fd147a | 19 | |
maetugr | 5:06e978fd147a | 20 | void SetFrequency(int frequency); |
maetugr | 5:06e978fd147a | 21 | |
maetugr | 5:06e978fd147a | 22 | /** Change the position of the servo. Position in us |
maetugr | 5:06e978fd147a | 23 | * |
maetugr | 5:06e978fd147a | 24 | * @param position The new value of the servos position between 0 and 1000 (gets 1000-2000) (us) |
maetugr | 5:06e978fd147a | 25 | */ |
maetugr | 5:06e978fd147a | 26 | void SetPosition(int position); |
maetugr | 5:06e978fd147a | 27 | |
maetugr | 5:06e978fd147a | 28 | /** Operator for confortable positioning |
maetugr | 5:06e978fd147a | 29 | * |
maetugr | 5:06e978fd147a | 30 | * @param position see SetPosition |
maetugr | 5:06e978fd147a | 31 | */ |
maetugr | 5:06e978fd147a | 32 | void operator=(int position); |
maetugr | 5:06e978fd147a | 33 | |
maetugr | 5:06e978fd147a | 34 | private: |
maetugr | 5:06e978fd147a | 35 | PwmOut ServoPin; |
maetugr | 5:06e978fd147a | 36 | |
maetugr | 5:06e978fd147a | 37 | }; |
maetugr | 5:06e978fd147a | 38 | |
maetugr | 0:12950aa67f2a | 39 | #endif |