Slow version

Dependencies:   mbed

Fork of SunflowerMach1 by Milan Draganic

Motor.cpp

Committer:
mdraganic
Date:
2013-11-08
Revision:
0:7447b8021b33
Child:
1:2e7d4aa6e79e

File content as of revision 0:7447b8021b33:

#include "Motor.h"

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;
    }
    
    wait_ms(motorDriveTime);
}

void Motor::stop() {

    positiveOut = 0;
    negativeOut = 0;
    direction = 0;
}