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 ECE 111 At Oregon State University

Committer:
ziadeldebri
Date:
Mon Sep 19 17:06:45 2016 +0000
Revision:
3:b787aa49b900
Parent:
2:3540e1f2f0e1
Child:
6:65dfd3886629
Scott 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 3:b787aa49b900 3 #include "SLCD.h"
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 3:b787aa49b900 15 * Servo my_servo(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 1:aa0b85d0961c 25 /** Create a servo object.
ziadeldebri 0:61b18b631f94 26 *
ziadeldebri 2:3540e1f2f0e1 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);
ziadeldebri 0:61b18b631f94 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);
ziadeldebri 0:61b18b631f94 36
ziadeldebri 0:61b18b631f94 37 /** Read the servo current position in degrees from 0-180
ziadeldebri 0:61b18b631f94 38 *
ziadeldebri 3:b787aa49b900 39 * @return returns the current anlge of the servo
ziadeldebri 3:b787aa49b900 40 */
ziadeldebri 0:61b18b631f94 41
ziadeldebri 3:b787aa49b900 42 void move(void);
ziadeldebri 3:b787aa49b900 43
ziadeldebri 3:b787aa49b900 44 void check();
ziadeldebri 0:61b18b631f94 45 protected:
ziadeldebri 0:61b18b631f94 46 AnalogIn _feedback;
ziadeldebri 3:b787aa49b900 47 Motor _motor;
ziadeldebri 0:61b18b631f94 48 };
ziadeldebri 0:61b18b631f94 49
ziadeldebri 0:61b18b631f94 50 #endif
ziadeldebri 0:61b18b631f94 51