Simply creates a servo object from a motor object, to allow the control of the angle.
Dependencies: mbed
Fork of Lab5_Basic by
Diff: Motor.cpp
- Revision:
- 12:988fb6ffae63
- Parent:
- 3:b787aa49b900
--- a/Motor.cpp Fri Nov 03 22:06:05 2017 +0000 +++ b/Motor.cpp Fri Nov 03 19:28:37 2017 -0700 @@ -5,9 +5,9 @@ Motor::Motor(PinName Positive, PinName Negative,PinName Speed): _positive(Positive), _negative(Negative), _speed(Speed) { - _speed.period(0.03f); // - _speed.write(0.45f); -} + _speed.period(0.03f); // + _speed.write(0.45f); +} /* Input 1 or 2. * 1 : Postive VCC Negtaive GND, 2 : Postive GND Negtaive VCC. */ @@ -16,23 +16,23 @@ _positive = 1; _negative = 0; } - else if(move == 2){ + else if(move == 2){ _positive = 0; _negative = 1; } }//End of Direction - + /* No input. - * 1 : Postive GND Negtaive GND + * 1 : Postive GND Negtaive GND */ void Motor::Stop() { _positive = 0; _negative = 0; }//End of Stop /* input is the . - * 1 : Postive GND Negtaive GND + * 1 : Postive GND Negtaive GND */ void Motor::Speed(int motor_speed) { float percantage = motor_speed/100; - _speed.write(percantage); - }//End of Stop \ No newline at end of file + _speed.write(percantage); + }//End of Stop