motor i senzor
Dependencies: TextLCD mbed PinDetect
MotorDrivers/Motor.cpp
- Committer:
- mdraganic
- Date:
- 2013-11-09
- Revision:
- 1:3500bf8487d0
- Child:
- 3:bebfc64cefe4
File content as of revision 1:3500bf8487d0:
#include "Motor.h" Motor::Motor() : positiveOut(NC), negativeOut(NC) { } Motor::Motor(PinName positivePin, PinName negativePin): positiveOut(positivePin), negativeOut(negativePin) { } void Motor::movePositive() { direction = 1; move(); } void Motor::moveNegative() { direction = -1; move(); } void Motor::move() { positiveOut = 0; negativeOut = 0; switch(direction) { case 0: return; case 1: positiveOut = 1; break; case -1: negativeOut = 1; break; } direction = 0; wait_ms(motorDriveTime); } void Motor::stop() { positiveOut = 0; negativeOut = 0; direction = 0; }