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.
Dependencies: mbed
Fork of Lab5_Basic by
Servo.h
- Committer:
- ziadeldebri
- Date:
- 2016-08-17
- Revision:
- 2:3540e1f2f0e1
- Parent:
- 1:aa0b85d0961c
- Child:
- 3:b787aa49b900
File content as of revision 2:3540e1f2f0e1:
#include "Motor.h"
#include "mbed.h"
#ifndef MBED_SERVO_H
#define MBED_SERVO_H
/** Servo control class, based on a Motor Class object
*
* Example:
* @code
* #include "mbed.h"
* #include "Motor.h"
* #include "Servo.h"
* Motor my_motor(P12,P13P,p11);
* Servo myservo(p21,my_motor);
*
* int main() {
*
* }
* @endcode
*/
class Servo {
public:
/** Create a servo object.
*
* @param pin AnalogIn pin to be feedback, motor is a Motor object from Motor.h
*/
Servo(PinName pin,Motor motor);
/** Set the servo position
*
* @param angle intger in degrees 0-180 to represent the full range.
*/
void write(float percent);
/** Read the servo current position in degrees from 0-180
*
* @param returns the current anlge of the servo
*/
int read();
protected:
AnalogIn _feedback;
};
#endif
