Mouse code for the MacroRat
Diff: motor.cpp
- Revision:
- 15:b80555a4a8b9
- Parent:
- 13:2032db00f168
diff -r 9e7bb03ddccb -r b80555a4a8b9 motor.cpp --- a/motor.cpp Sat May 13 23:49:02 2017 +0000 +++ b/motor.cpp Sun May 14 04:45:21 2017 +0000 @@ -7,8 +7,9 @@ }else if(voltage < minSpeed){ voltage = minSpeed; } - forw.write(voltage); - back.write(0); + enableForw.write(0); + enableBack.write(1); + motorSpeed.write( voltage ); } void Motor::forward(double voltage) { @@ -17,8 +18,9 @@ }else if(voltage < minSpeed){ voltage = minSpeed; } - forw.write(0); - back.write(voltage); + enableForw.write(1); + enableBack.write(0); + motorSpeed.write( voltage ); } void Motor::move(double voltage) { @@ -32,11 +34,13 @@ void Motor::brake() { - forw.write(BRAKE_VOLTAGE); - back.write(BRAKE_VOLTAGE); + enableForw.write(1); + enableBack.write(1); + motorSpeed.write( BRAKE_VOLTAGE ); } void Motor::coast() { - forw.write(0); - back.write(0); + enableForw.write(0); + enableBack.write(0); + motorSpeed.write( 0 ); } \ No newline at end of file