Added various bits, main reformatted. Added .get to class Servo to allow waiting for rotation before recording information.
Fork of Lab6_Basic by
Motor.h@3:b787aa49b900, 2016-09-19 (annotated)
- Committer:
- ziadeldebri
- Date:
- Mon Sep 19 17:06:45 2016 +0000
- Revision:
- 3:b787aa49b900
- Child:
- 6:a64d79286726
Scott Test;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ziadeldebri | 3:b787aa49b900 | 1 | #include "mbed.h" |
ziadeldebri | 3:b787aa49b900 | 2 | #ifndef MOTOR_H |
ziadeldebri | 3:b787aa49b900 | 3 | #define MOTOR_H |
ziadeldebri | 3:b787aa49b900 | 4 | /** Motor class |
ziadeldebri | 3:b787aa49b900 | 5 | * \author Ziad Eldebri |
ziadeldebri | 3:b787aa49b900 | 6 | * \date Aug 15, 2016 |
ziadeldebri | 3:b787aa49b900 | 7 | * \bug No bugs yet |
ziadeldebri | 3:b787aa49b900 | 8 | * Example: |
ziadeldebri | 3:b787aa49b900 | 9 | * @code |
ziadeldebri | 3:b787aa49b900 | 10 | * #include "mbed.h" |
ziadeldebri | 3:b787aa49b900 | 11 | * #include "Motor.h" |
ziadeldebri | 3:b787aa49b900 | 12 | * |
ziadeldebri | 3:b787aa49b900 | 13 | * Motor my_motor(P12,P13P,p11); |
ziadeldebri | 3:b787aa49b900 | 14 | * |
ziadeldebri | 3:b787aa49b900 | 15 | * int main() { |
ziadeldebri | 3:b787aa49b900 | 16 | * my_motor.Direction(LEFT); will move in the specified direction |
ziadeldebri | 3:b787aa49b900 | 17 | * } |
ziadeldebri | 3:b787aa49b900 | 18 | * @endcode |
ziadeldebri | 3:b787aa49b900 | 19 | */ |
ziadeldebri | 3:b787aa49b900 | 20 | |
ziadeldebri | 3:b787aa49b900 | 21 | #define LEFT 1 |
ziadeldebri | 3:b787aa49b900 | 22 | #define RIGHT 2 |
ziadeldebri | 3:b787aa49b900 | 23 | |
ziadeldebri | 3:b787aa49b900 | 24 | |
ziadeldebri | 3:b787aa49b900 | 25 | class Motor |
ziadeldebri | 3:b787aa49b900 | 26 | { |
ziadeldebri | 3:b787aa49b900 | 27 | public: |
ziadeldebri | 3:b787aa49b900 | 28 | /** |
ziadeldebri | 3:b787aa49b900 | 29 | * Motor Will Create a Motor object Connected to the Specified pins. |
ziadeldebri | 3:b787aa49b900 | 30 | * @param Pins to be Connected to the specified L293 http://www.ti.com/lit/ds/symlink/l293.pdf |
ziadeldebri | 3:b787aa49b900 | 31 | * @param Positive |
ziadeldebri | 3:b787aa49b900 | 32 | * @param Negative |
ziadeldebri | 3:b787aa49b900 | 33 | * @param Speed |
ziadeldebri | 3:b787aa49b900 | 34 | */ |
ziadeldebri | 3:b787aa49b900 | 35 | Motor (PinName Positive, PinName Negative,PinName Speed); |
ziadeldebri | 3:b787aa49b900 | 36 | /** |
ziadeldebri | 3:b787aa49b900 | 37 | * Control the Direction of the Movement |
ziadeldebri | 3:b787aa49b900 | 38 | * @param move will specefiy the Direction. |
ziadeldebri | 3:b787aa49b900 | 39 | * Input 1 or 2. |
ziadeldebri | 3:b787aa49b900 | 40 | * 1 : Postive VCC Negtaive GND, 2 : Postive GND Negtaive VCC |
ziadeldebri | 3:b787aa49b900 | 41 | */ |
ziadeldebri | 3:b787aa49b900 | 42 | void Direction(int move); |
ziadeldebri | 3:b787aa49b900 | 43 | /** |
ziadeldebri | 3:b787aa49b900 | 44 | * Stops the Movement of the motor |
ziadeldebri | 3:b787aa49b900 | 45 | * @param None. |
ziadeldebri | 3:b787aa49b900 | 46 | * Input 1 or 2. |
ziadeldebri | 3:b787aa49b900 | 47 | */ |
ziadeldebri | 3:b787aa49b900 | 48 | void Stop(); |
ziadeldebri | 3:b787aa49b900 | 49 | /** |
ziadeldebri | 3:b787aa49b900 | 50 | * Controls the speed of the motor with a input. |
ziadeldebri | 3:b787aa49b900 | 51 | * @param motor_speed from 0 to 100. 0 is the slowest and 100 is max speed. |
ziadeldebri | 3:b787aa49b900 | 52 | * |
ziadeldebri | 3:b787aa49b900 | 53 | */ |
ziadeldebri | 3:b787aa49b900 | 54 | void Speed(int motor_speed); |
ziadeldebri | 3:b787aa49b900 | 55 | |
ziadeldebri | 3:b787aa49b900 | 56 | protected: |
ziadeldebri | 3:b787aa49b900 | 57 | DigitalOut _positive; |
ziadeldebri | 3:b787aa49b900 | 58 | DigitalOut _negative; |
ziadeldebri | 3:b787aa49b900 | 59 | PwmOut _speed; |
ziadeldebri | 3:b787aa49b900 | 60 | |
ziadeldebri | 3:b787aa49b900 | 61 | |
ziadeldebri | 3:b787aa49b900 | 62 | }; //end of Motor class |
ziadeldebri | 3:b787aa49b900 | 63 | #endif |