AF_TB6612FNG is a library of TB6612FNG.
Example
include the mbed library with this snippet
#include "mbed.h" #include "AF_TB6612FNG.h" AF_TB6612FNG tb6612fng(p21, p20, p19, p22, p18, p17, p12); int main() { float speed = 0.6; tb6612fng.forward(speed); }
AF_TB6612FNG.cpp
- Committer:
- tichise
- Date:
- 2018-06-04
- Revision:
- 0:98dcc458e267
- Child:
- 2:d6cb78f523b0
File content as of revision 0:98dcc458e267:
#include "AF_TB6612FNG.h" #include "mbed.h" AF_TB6612FNG::AF_TB6612FNG(PinName pwma, PinName ain1, PinName ain2, PinName pwmb, PinName bin1, PinName bin2, PinName standby) : _motorL(pwma,ain1,ain2),_motorR(pwmb,bin1,bin2),_standby(standby) { _isForward = false; _standby = 1; } void AF_TB6612FNG::stop() { _motorL = 0; _motorR = 0; } void AF_TB6612FNG::forward(float speed) { _motorL = speed; _motorR = speed; _isForward = true; } void AF_TB6612FNG::back(float speed) { _motorL = -1*speed; _motorR = -1*speed; _isForward = true; } void AF_TB6612FNG::left(float speed) { _motorL = -1*speed; _motorR = speed; } void AF_TB6612FNG::right(float speed) { _motorL = speed; _motorR = -1*speed; } void AF_TB6612FNG::setISForward(bool isForward) { _isForward = isForward; } bool AF_TB6612FNG::isForward() { return _isForward; }