cleaned up motor class with separate header and .cpp files

Dependencies:   mbed

Dependents:   TerraBot_Drive_2D TerraBot_Drive_2D TerraBot_Drive_2D_FINAL DUMP_TRUCK_Test ... more

Motor.cpp

Committer:
simplyellow
Date:
2017-02-14
Revision:
4:e87768d3cd09
Parent:
1:92be353590b4

File content as of revision 4:e87768d3cd09:

#include "Motor.h"

Motor::Motor(PinName pwm, PinName dir) : pwmPin(pwm), dirPin(dir)
    {
    }

void Motor::write(float Val)
{
      if (Val >= 0) {
        dirPin = 1;
        pwmPin = Val;
        }else {
            dirPin = 0;
            pwmPin = -1 * Val;
    }
    lastVal = Val;
}
   
float Motor::read()
{
        return lastVal;
}