Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: measure_1_BBB measure_1_CCC measure_1_DDD
TB6612FNG.cpp@1:4c4f2d25dc05, 2021-05-13 (annotated)
- Committer:
- sato_shi
- Date:
- Thu May 13 05:11:37 2021 +0000
- Revision:
- 1:4c4f2d25dc05
- Parent:
- 0:085abb7f6992
BBBBBBb;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Satoshisatoshi | 0:085abb7f6992 | 1 | #include "mbed.h" |
| Satoshisatoshi | 0:085abb7f6992 | 2 | #include "TB6612FNG.h" |
| Satoshisatoshi | 0:085abb7f6992 | 3 | |
| Satoshisatoshi | 0:085abb7f6992 | 4 | TB6612FNG::TB6612FNG(PinName IN1, PinName IN2, PinName STBY, PinName PWM): |
| Satoshisatoshi | 0:085abb7f6992 | 5 | _IN1(IN1), _IN2(IN2), _STBY(STBY), _PWM(PWM) |
| Satoshisatoshi | 0:085abb7f6992 | 6 | { |
| Satoshisatoshi | 0:085abb7f6992 | 7 | _PWM = 0; |
| Satoshisatoshi | 0:085abb7f6992 | 8 | } |
| Satoshisatoshi | 0:085abb7f6992 | 9 | |
| Satoshisatoshi | 0:085abb7f6992 | 10 | void TB6612FNG::STBY(bool f) |
| Satoshisatoshi | 0:085abb7f6992 | 11 | { |
| Satoshisatoshi | 0:085abb7f6992 | 12 | _STBY = f; |
| Satoshisatoshi | 0:085abb7f6992 | 13 | } |
| Satoshisatoshi | 0:085abb7f6992 | 14 | |
| Satoshisatoshi | 0:085abb7f6992 | 15 | void TB6612FNG::SetW(float W) |
| sato_shi | 1:4c4f2d25dc05 | 16 | { |
| sato_shi | 1:4c4f2d25dc05 | 17 | if(0 <= W && W <= 1) _PWM = W; |
| sato_shi | 1:4c4f2d25dc05 | 18 | else if(1 < W) _PWM = 1; |
| sato_shi | 1:4c4f2d25dc05 | 19 | else _PWM = 0; |
| sato_shi | 1:4c4f2d25dc05 | 20 | |
| Satoshisatoshi | 0:085abb7f6992 | 21 | } |
| Satoshisatoshi | 0:085abb7f6992 | 22 | |
| Satoshisatoshi | 0:085abb7f6992 | 23 | void TB6612FNG::Forward() |
| Satoshisatoshi | 0:085abb7f6992 | 24 | { |
| Satoshisatoshi | 0:085abb7f6992 | 25 | _IN1 = 1; |
| Satoshisatoshi | 0:085abb7f6992 | 26 | _IN2 = 0; |
| Satoshisatoshi | 0:085abb7f6992 | 27 | } |
| Satoshisatoshi | 0:085abb7f6992 | 28 | |
| Satoshisatoshi | 0:085abb7f6992 | 29 | void TB6612FNG::Stop() |
| Satoshisatoshi | 0:085abb7f6992 | 30 | { |
| Satoshisatoshi | 0:085abb7f6992 | 31 | _IN1 = 0; |
| Satoshisatoshi | 0:085abb7f6992 | 32 | _IN2 = 0; |
| Satoshisatoshi | 0:085abb7f6992 | 33 | } |
| Satoshisatoshi | 0:085abb7f6992 | 34 | |
| Satoshisatoshi | 0:085abb7f6992 | 35 | /* |
| Satoshisatoshi | 0:085abb7f6992 | 36 | void TB6612FNG::Reverse(byte rpm); |
| Satoshisatoshi | 0:085abb7f6992 | 37 | void TB6612FNG::Stop(byte rpm); |
| Satoshisatoshi | 0:085abb7f6992 | 38 | void TB6612FNG::Brake(byte rpm); |
| Satoshisatoshi | 0:085abb7f6992 | 39 | */ |
| Satoshisatoshi | 0:085abb7f6992 | 40 | |
| Satoshisatoshi | 0:085abb7f6992 | 41 |