Added various bits, main reformatted. Added .get to class Servo to allow waiting for rotation before recording information.

Dependencies:   SLCD mbed

Fork of Lab6_Basic by ECE 111 At Oregon State University

Committer:
ziadeldebri
Date:
Wed Aug 17 19:07:22 2016 +0000
Revision:
0:61b18b631f94
Child:
1:aa0b85d0961c
API test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ziadeldebri 0:61b18b631f94 1 #include "Motor.h"
ziadeldebri 0:61b18b631f94 2 #include "mbed.h"
ziadeldebri 0:61b18b631f94 3
ziadeldebri 0:61b18b631f94 4 #ifndef MBED_SERVO_H
ziadeldebri 0:61b18b631f94 5 #define MBED_SERVO_H
ziadeldebri 0:61b18b631f94 6
ziadeldebri 0:61b18b631f94 7 /** Servo control class, based on a Motor Class object
ziadeldebri 0:61b18b631f94 8 *
ziadeldebri 0:61b18b631f94 9 * Example:
ziadeldebri 0:61b18b631f94 10 * @code
ziadeldebri 0:61b18b631f94 11 * #include "mbed.h"
ziadeldebri 0:61b18b631f94 12 * #include "Motor.h"
ziadeldebri 0:61b18b631f94 13 * #include "Servo.h"
ziadeldebri 0:61b18b631f94 14 * Motor my_motor(P12,P13P,p11);
ziadeldebri 0:61b18b631f94 15 * Servo myservo(p21,my_motor);
ziadeldebri 0:61b18b631f94 16 *
ziadeldebri 0:61b18b631f94 17 * int main() {
ziadeldebri 0:61b18b631f94 18 *
ziadeldebri 0:61b18b631f94 19 * }
ziadeldebri 0:61b18b631f94 20 * @endcode
ziadeldebri 0:61b18b631f94 21 */
ziadeldebri 0:61b18b631f94 22 class Servo {
ziadeldebri 0:61b18b631f94 23
ziadeldebri 0:61b18b631f94 24 public:
ziadeldebri 0:61b18b631f94 25 /** Create a servo object connected to the specified PwmOut pin
ziadeldebri 0:61b18b631f94 26 *
ziadeldebri 0:61b18b631f94 27 * @param pin AnalogIn pin to be feedback
ziadeldebri 0:61b18b631f94 28 */
ziadeldebri 0:61b18b631f94 29 Servo(PinName pin,Motor motor);
ziadeldebri 0:61b18b631f94 30
ziadeldebri 0:61b18b631f94 31 /** Set the servo position, normalised to it's full range
ziadeldebri 0:61b18b631f94 32 *
ziadeldebri 0:61b18b631f94 33 * @param percent an angle number in degrees 0-180 to represent the full range.
ziadeldebri 0:61b18b631f94 34 */
ziadeldebri 0:61b18b631f94 35 void write(float percent);
ziadeldebri 0:61b18b631f94 36
ziadeldebri 0:61b18b631f94 37 /** Read the servo current position in degrees from 0-180
ziadeldebri 0:61b18b631f94 38 *
ziadeldebri 0:61b18b631f94 39 * @param returns the current anlge of the servo
ziadeldebri 0:61b18b631f94 40 */
ziadeldebri 0:61b18b631f94 41 int read();
ziadeldebri 0:61b18b631f94 42
ziadeldebri 0:61b18b631f94 43 protected:
ziadeldebri 0:61b18b631f94 44 AnalogIn _feedback;
ziadeldebri 0:61b18b631f94 45 };
ziadeldebri 0:61b18b631f94 46
ziadeldebri 0:61b18b631f94 47 #endif
ziadeldebri 0:61b18b631f94 48