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
00001 #include "Motor.h" 00002 00003 Motor::Motor(PinName pwm, PinName dir) : pwmPin(pwm), dirPin(dir) 00004 { 00005 } 00006 00007 void Motor::write(float Val) 00008 { 00009 if (Val >= 0) { 00010 dirPin = 1; 00011 pwmPin = Val; 00012 }else { 00013 dirPin = 0; 00014 pwmPin = -1 * Val; 00015 } 00016 lastVal = Val; 00017 } 00018 00019 float Motor::read() 00020 { 00021 return lastVal; 00022 }
Generated on Thu Jul 14 2022 07:23:14 by 1.7.2