Library is coded to control servo This library is part of my project which is built on FRDM-KL25Z and motor shield l293D v1
ServoMotorControl.h@0:22a971e060ed, 2017-09-24 (annotated)
- Committer:
- vtqNhi
- Date:
- Sun Sep 24 18:41:24 2017 +0000
- Revision:
- 0:22a971e060ed
This library is created to control servo motor by send pulsewidth to pwm pin.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vtqNhi | 0:22a971e060ed | 1 | #ifndef MBED_SERVO_H |
vtqNhi | 0:22a971e060ed | 2 | #define MBED_SERVO_H |
vtqNhi | 0:22a971e060ed | 3 | |
vtqNhi | 0:22a971e060ed | 4 | #include "mbed.h" |
vtqNhi | 0:22a971e060ed | 5 | |
vtqNhi | 0:22a971e060ed | 6 | class Servo |
vtqNhi | 0:22a971e060ed | 7 | { |
vtqNhi | 0:22a971e060ed | 8 | public: |
vtqNhi | 0:22a971e060ed | 9 | Servo(PinName pwm); |
vtqNhi | 0:22a971e060ed | 10 | void turn2Angle(int degree); |
vtqNhi | 0:22a971e060ed | 11 | void turn2pulse(float value); |
vtqNhi | 0:22a971e060ed | 12 | float positionRead(); |
vtqNhi | 0:22a971e060ed | 13 | private: |
vtqNhi | 0:22a971e060ed | 14 | PwmOut _pwm; |
vtqNhi | 0:22a971e060ed | 15 | float _position; |
vtqNhi | 0:22a971e060ed | 16 | }; |
vtqNhi | 0:22a971e060ed | 17 | |
vtqNhi | 0:22a971e060ed | 18 | #endif |