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 "TI_TB6612FNG.h"
tichise 0:982bd54e15b1 2 #include "mbed.h"
tichise 0:982bd54e15b1 3
tichise 0:982bd54e15b1 4 TI_TB6612FNG::TI_TB6612FNG(PinName pwma, PinName ain1, PinName ain2, PinName pwmb, PinName bin1, PinName bin2, PinName standby)
tichise 0:982bd54e15b1 5 : _motorL(pwma,ain1,ain2),_motorR(pwmb,bin1,bin2),_standby(standby) {
tichise 0:982bd54e15b1 6 _isForward = false;
tichise 0:982bd54e15b1 7 _standby = 1;
tichise 0:982bd54e15b1 8 }
tichise 0:982bd54e15b1 9
tichise 0:982bd54e15b1 10 void TI_TB6612FNG::stop()
tichise 0:982bd54e15b1 11 {
tichise 0:982bd54e15b1 12 _motorL = 0;
tichise 0:982bd54e15b1 13 _motorR = 0;
tichise 0:982bd54e15b1 14 _isForward = false;
tichise 0:982bd54e15b1 15 }
tichise 0:982bd54e15b1 16
tichise 0:982bd54e15b1 17 void TI_TB6612FNG::forward(float speed)
tichise 0:982bd54e15b1 18 {
tichise 0:982bd54e15b1 19 _motorL = speed;
tichise 0:982bd54e15b1 20 _motorR = speed;
tichise 0:982bd54e15b1 21 _isForward = true;
tichise 0:982bd54e15b1 22 }
tichise 0:982bd54e15b1 23
tichise 0:982bd54e15b1 24 void TI_TB6612FNG::backward(float speed)
tichise 0:982bd54e15b1 25 {
tichise 0:982bd54e15b1 26 _motorL = -1*speed;
tichise 0:982bd54e15b1 27 _motorR = -1*speed;
tichise 0:982bd54e15b1 28 _isForward = false;
tichise 0:982bd54e15b1 29 }
tichise 0:982bd54e15b1 30
tichise 0:982bd54e15b1 31 void TI_TB6612FNG::left(float speed)
tichise 0:982bd54e15b1 32 {
tichise 0:982bd54e15b1 33 _motorL = -1*speed;
tichise 0:982bd54e15b1 34 _motorR = speed;
tichise 0:982bd54e15b1 35 _isForward = false;
tichise 0:982bd54e15b1 36 }
tichise 0:982bd54e15b1 37
tichise 0:982bd54e15b1 38 void TI_TB6612FNG::right(float speed)
tichise 0:982bd54e15b1 39 {
tichise 0:982bd54e15b1 40 _motorL = speed;
tichise 0:982bd54e15b1 41 _motorR = -1*speed;
tichise 0:982bd54e15b1 42 _isForward = false;
tichise 0:982bd54e15b1 43 }
tichise 0:982bd54e15b1 44
tichise 0:982bd54e15b1 45 bool TI_TB6612FNG::isForward() {
tichise 0:982bd54e15b1 46 return _isForward;
tichise 0:982bd54e15b1 47 }