TI_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);
}
Committer:
tichise
Date:
Mon Jun 04 23:14:18 2018 +0000
Revision:
0:982bd54e15b1
new

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tichise 0:982bd54e15b1 1 #include "Moter.h"
tichise 0:982bd54e15b1 2
tichise 0:982bd54e15b1 3 Moter::Moter(PinName pwm, PinName in1, PinName in2):_pwm(pwm), _in1(in1), _in2(in2)
tichise 0:982bd54e15b1 4 {
tichise 0:982bd54e15b1 5 _in1 = 0;
tichise 0:982bd54e15b1 6 _in2 = 0;
tichise 0:982bd54e15b1 7 _pwm = 0.0;
tichise 0:982bd54e15b1 8
tichise 0:982bd54e15b1 9 _pwm.period(0.001);
tichise 0:982bd54e15b1 10 }
tichise 0:982bd54e15b1 11
tichise 0:982bd54e15b1 12 float Moter::speed(float speed)
tichise 0:982bd54e15b1 13 {
tichise 0:982bd54e15b1 14 if(speed > 0.0) {
tichise 0:982bd54e15b1 15 _pwm = speed;
tichise 0:982bd54e15b1 16 _in1 = 1;
tichise 0:982bd54e15b1 17 _in2 = 0;
tichise 0:982bd54e15b1 18 } else if(speed < 0.0) {
tichise 0:982bd54e15b1 19 _pwm = -speed;
tichise 0:982bd54e15b1 20 _in1 = 0;
tichise 0:982bd54e15b1 21 _in2 = 1;
tichise 0:982bd54e15b1 22 } else {
tichise 0:982bd54e15b1 23 _in1 = 1;
tichise 0:982bd54e15b1 24 _in2 = 1;
tichise 0:982bd54e15b1 25 }
tichise 0:982bd54e15b1 26
tichise 0:982bd54e15b1 27 return speed == 0 ? 0 : speed > 0 ? 1 : -1;
tichise 0:982bd54e15b1 28 }