This library is an attempt to encapsulate the Pololu motor board.
Motor.cpp
- Committer:
- buckeyes1997
- Date:
- 2013-02-11
- Revision:
- 0:b7c4b6de973e
- Child:
- 1:69e4a93b718d
File content as of revision 0:b7c4b6de973e:
#include "Motor.h" #include "mbed.h" Motor::Motor(PinName pwm, PinName dir1, PinName dir2): _pwm(pwm), _dir1(dir1), _dir2(dir2) { _direction=1; _pwm.period(0.00005); _pwm = 0; _dir1 = 0; _dir2 = 0; } float Motor::speed(float speed, bool direction) { if(direction == true) { _dir1=1; _dir2=0; } else { _dir1=0; _dir2=1; } _pwm = abs(speed); return speed; } float Motor::speed(float speed) { _pwm = abs(speed); return speed; } Motor& Motor::operator= (float speed) { _pwm = abs(speed); return *this; }