basic motor controller class to be used with the TB6612 motor controller.
motor.cpp
- Committer:
- snapo
- Date:
- 2021-10-31
- Revision:
- 0:322cf8e3ef05
File content as of revision 0:322cf8e3ef05:
#include "motor.h" motor::motor(PinName dir1, PinName dir2, PinName motorOne): dir1_(dir1), dir2_(dir2), motorOne_(motorOne) {} void motor::setSpeed(float speed){ if (speed > 0){ dir1_ = true; dir2_ = false; motorOne_ = speed; } else { dir1_ = false; dir2_ = true; motorOne_ = speed; } } motor & motor::operator = (float speed){ setSpeed(speed); return *this; }