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.
MotorDriver.cpp
- Committer:
- khaiminhvn
- Date:
- 2021-02-09
- Revision:
- 0:c58a5bbd417a
File content as of revision 0:c58a5bbd417a:
//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; }