Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: MotorDriver.cpp
- Revision:
- 0:c58a5bbd417a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MotorDriver.cpp Tue Feb 09 23:53:44 2021 +0000 @@ -0,0 +1,58 @@ +//INCLUDES +#include "MotorDriver.h" +#include "PinAssignment.h" + +MotorDriver::MotorDriver() : ena(PIN_ENA),enb(PIN_ENB),intp(PIN_INTP),intn(PIN_INTN) {} + +//moveForward +void MotorDriver::moveForward(int s) +{ + switch(s) + { + case M1: + ena = 1; + enb = 0; + break; + case M2: + ena = 0; + enb = 1; + break; + case M_ALL: + ena = 1; + enb = 1; + break; + } + intp = 1; + intn = 0; +} + +//moveBackward +void MotorDriver::moveBackward(int s) +{ + switch(s) + { + case M1: + ena = 1; + enb = 0; + break; + case M2: + ena = 0; + enb = 1; + break; + case M_ALL: + ena = 1; + enb = 1; + break; + } + intp = 0; + intn = 1; +} + +//stop +void MotorDriver::stop() +{ + ena = 0; + enb = 0; + intp = 0; + intn = 0; +} \ No newline at end of file