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