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); }
Revision 2:d6cb78f523b0, committed 2018-06-04
- Comitter:
- tichise
- Date:
- Mon Jun 04 00:43:00 2018 +0000
- Parent:
- 1:47e5a7b22c0f
- Commit message:
- refactoring
Changed in this revision
AF_TB6612FNG.cpp | Show annotated file Show diff for this revision Revisions of this file |
AF_TB6612FNG.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 47e5a7b22c0f -r d6cb78f523b0 AF_TB6612FNG.cpp --- a/AF_TB6612FNG.cpp Mon Jun 04 00:36:29 2018 +0000 +++ b/AF_TB6612FNG.cpp Mon Jun 04 00:43:00 2018 +0000 @@ -11,6 +11,7 @@ { _motorL = 0; _motorR = 0; + _isForward = false; } void AF_TB6612FNG::forward(float speed) @@ -20,27 +21,25 @@ _isForward = true; } -void AF_TB6612FNG::back(float speed) +void AF_TB6612FNG::backward(float speed) { _motorL = -1*speed; _motorR = -1*speed; - _isForward = true; + _isForward = false; } void AF_TB6612FNG::left(float speed) { _motorL = -1*speed; _motorR = speed; + _isForward = false; } void AF_TB6612FNG::right(float speed) { _motorL = speed; _motorR = -1*speed; -} - -void AF_TB6612FNG::setISForward(bool isForward) { - _isForward = isForward; + _isForward = false; } bool AF_TB6612FNG::isForward() {
diff -r 47e5a7b22c0f -r d6cb78f523b0 AF_TB6612FNG.h --- a/AF_TB6612FNG.h Mon Jun 04 00:36:29 2018 +0000 +++ b/AF_TB6612FNG.h Mon Jun 04 00:43:00 2018 +0000 @@ -10,11 +10,10 @@ AF_TB6612FNG(PinName pwma, PinName ain1, PinName ain2, PinName pwmb, PinName bin1, PinName bin2, PinName standby); void stop(); void forward(float speed); - void back(float speed); + void backward(float speed); void left(float speed); void right(float speed); bool isForward(); - void setISForward(bool isForward); private: Moter _motorL;