Init
Dependents: JetflyerMotorController
Motor.cpp
- Committer:
- skrickl
- Date:
- 2017-07-13
- Revision:
- 1:39b173360768
- Parent:
- 0:5eb2bad9ea40
File content as of revision 1:39b173360768:
#include "Motor.h" Motor::Motor() : forward(pin_forward),backward(pin_backward),throttle(pin_pwm_motor) { direction_old = 1; } Motor::~Motor() { } //speed in percent int Motor::drive(int speed, int direction) { // if direction change is detected both pins are set to 0 if(direction_old != direction) { backward =0; forward = 0; } else { if(direction == 1) { backward =0; forward =1; } if(direction == -1) { backward =1; forward =0; } } throttle.write(((float)speed)/100.0f); direction_old = direction; return 0; }