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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Moter.cpp	Mon Jun 04 23:14:18 2018 +0000
@@ -0,0 +1,28 @@
+#include "Moter.h"
+
+Moter::Moter(PinName pwm, PinName in1, PinName in2):_pwm(pwm), _in1(in1), _in2(in2)
+{
+    _in1 = 0;
+    _in2 = 0;
+    _pwm = 0.0;
+
+    _pwm.period(0.001);
+}
+
+float Moter::speed(float speed)
+{
+    if(speed > 0.0) {
+        _pwm = speed;
+        _in1 = 1;
+        _in2 = 0;
+    } else if(speed < 0.0) {
+        _pwm = -speed;
+        _in1 = 0;
+        _in2 = 1;
+    } else {
+        _in1 = 1;
+        _in2 = 1;
+    }
+
+    return speed == 0 ? 0 : speed > 0 ? 1 : -1;
+}
\ No newline at end of file