TI_TB6612FNG is a library of TB6612FNG.

Dependents:   TI_TB6612FNG_SAMPLE

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:
0:982bd54e15b1
diff -r 000000000000 -r 982bd54e15b1 TI_TB6612FNG.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TI_TB6612FNG.cpp	Mon Jun 04 23:14:18 2018 +0000
@@ -0,0 +1,47 @@
+#include "TI_TB6612FNG.h"
+#include "mbed.h"
+
+TI_TB6612FNG::TI_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 TI_TB6612FNG::stop()
+{
+    _motorL = 0;
+    _motorR = 0;
+    _isForward = false;
+}
+
+void TI_TB6612FNG::forward(float speed)
+{
+    _motorL = speed;
+    _motorR = speed;
+    _isForward = true;
+}
+
+void TI_TB6612FNG::backward(float speed)
+{
+    _motorL = -1*speed;
+    _motorR = -1*speed;
+    _isForward = false;
+}
+
+void TI_TB6612FNG::left(float speed)
+{
+    _motorL = -1*speed;
+    _motorR = speed;
+    _isForward = false;
+}
+
+void TI_TB6612FNG::right(float speed)
+{
+    _motorL = speed;
+    _motorR = -1*speed;
+    _isForward = false;
+}
+
+bool TI_TB6612FNG::isForward() {
+    return _isForward;
+}
\ No newline at end of file