PRAWIRA
Motor.cpp
- Committer:
- alienbernamaihsan
- Date:
- 2019-09-16
- Revision:
- 0:86d90c65f83b
File content as of revision 0:86d90c65f83b:
#include "Motor.h" Motor::Motor(PinName dright, PinName dleft, PinName pwmpin): dright_(dright), dleft_(dleft), pwmpin_(pwmpin) { pwmpin_.period_us(50); } void Motor::setpwm(float inputpwm) { if (inputpwm >= 0) { dright_ = 1; dleft_ = 0; pwmpin_.write(inputpwm); } else { dright_ = 0; dleft_ = 1; pwmpin_.write(-1 * inputpwm); } }