Simply creates a servo object from a motor object, to allow the control of the angle. uses the solar panel to look for the brightest spot, then stops.
Dependencies: mbed
Fork of Lab6_Basic by
Servo.h@6:65dfd3886629, 2017-11-14 (annotated)
- Committer:
- dogcatfee
- Date:
- Tue Nov 14 13:02:54 2017 -0800
- Revision:
- 6:65dfd3886629
- Parent:
- 3:b787aa49b900
Update for KL43Z
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ziadeldebri | 0:61b18b631f94 | 1 | #include "Motor.h" |
ziadeldebri | 0:61b18b631f94 | 2 | #include "mbed.h" |
ziadeldebri | 3:b787aa49b900 | 3 | #include "SLCD.h" |
ziadeldebri | 0:61b18b631f94 | 4 | #ifndef MBED_SERVO_H |
ziadeldebri | 0:61b18b631f94 | 5 | #define MBED_SERVO_H |
dogcatfee | 6:65dfd3886629 | 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 | 3:b787aa49b900 | 15 | * Servo my_servo(p21,my_motor); |
dogcatfee | 6:65dfd3886629 | 16 | * |
ziadeldebri | 0:61b18b631f94 | 17 | * int main() { |
dogcatfee | 6:65dfd3886629 | 18 | * |
ziadeldebri | 0:61b18b631f94 | 19 | * } |
ziadeldebri | 0:61b18b631f94 | 20 | * @endcode |
ziadeldebri | 0:61b18b631f94 | 21 | */ |
ziadeldebri | 0:61b18b631f94 | 22 | class Servo { |
dogcatfee | 6:65dfd3886629 | 23 | |
ziadeldebri | 0:61b18b631f94 | 24 | public: |
ziadeldebri | 1:aa0b85d0961c | 25 | /** Create a servo object. |
ziadeldebri | 0:61b18b631f94 | 26 | * |
dogcatfee | 6:65dfd3886629 | 27 | * @param pin AnalogIn pin to be feedback, motor is a Motor object from Motor.h |
ziadeldebri | 0:61b18b631f94 | 28 | */ |
ziadeldebri | 3:b787aa49b900 | 29 | Servo(PinName analog_input,PinName Positive, PinName Negative,PinName Speed); |
dogcatfee | 6:65dfd3886629 | 30 | |
ziadeldebri | 2:3540e1f2f0e1 | 31 | /** Set the servo position |
ziadeldebri | 0:61b18b631f94 | 32 | * |
ziadeldebri | 2:3540e1f2f0e1 | 33 | * @param angle intger in degrees 0-180 to represent the full range. |
ziadeldebri | 0:61b18b631f94 | 34 | */ |
ziadeldebri | 3:b787aa49b900 | 35 | void set(int degree); |
dogcatfee | 6:65dfd3886629 | 36 | |
ziadeldebri | 0:61b18b631f94 | 37 | /** Read the servo current position in degrees from 0-180 |
ziadeldebri | 0:61b18b631f94 | 38 | * |
dogcatfee | 6:65dfd3886629 | 39 | * @return returns the current anlge of the servo |
dogcatfee | 6:65dfd3886629 | 40 | */ |
dogcatfee | 6:65dfd3886629 | 41 | |
ziadeldebri | 3:b787aa49b900 | 42 | void move(void); |
dogcatfee | 6:65dfd3886629 | 43 | |
dogcatfee | 6:65dfd3886629 | 44 | void check(); |
dogcatfee | 6:65dfd3886629 | 45 | |
dogcatfee | 6:65dfd3886629 | 46 | unsigned int get(); |
dogcatfee | 6:65dfd3886629 | 47 | |
ziadeldebri | 3:b787aa49b900 | 48 | |
ziadeldebri | 0:61b18b631f94 | 49 | protected: |
ziadeldebri | 0:61b18b631f94 | 50 | AnalogIn _feedback; |
ziadeldebri | 3:b787aa49b900 | 51 | Motor _motor; |
ziadeldebri | 0:61b18b631f94 | 52 | }; |
dogcatfee | 6:65dfd3886629 | 53 | |
ziadeldebri | 0:61b18b631f94 | 54 | #endif |