Junichi Katsu
/
JBB_Motor_test
It is a motor driver test program Jksoft Blue mbed Board. Jksoft Blue mbed Boardのモータードライバテストプログラムです。
main.cpp@1:c49f6eb130b4, 2014-05-12 (annotated)
- Committer:
- jksoft
- Date:
- Mon May 12 14:11:06 2014 +0000
- Revision:
- 1:c49f6eb130b4
- Parent:
- 0:effe57895c37
2nd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:effe57895c37 | 1 | #include "mbed.h" |
jksoft | 1:c49f6eb130b4 | 2 | #include "TB6612.h" |
jksoft | 0:effe57895c37 | 3 | |
jksoft | 1:c49f6eb130b4 | 4 | TB6612 MOTOR_A(p21,p19,p20); // PWM IN1 IN2 |
jksoft | 1:c49f6eb130b4 | 5 | TB6612 MOTOR_B(p22,p29,p30); // PWM IN1 IN2 |
jksoft | 1:c49f6eb130b4 | 6 | DigitalIn SW1(p25); |
jksoft | 1:c49f6eb130b4 | 7 | DigitalIn SW2(p26); |
jksoft | 0:effe57895c37 | 8 | |
jksoft | 0:effe57895c37 | 9 | int main() { |
jksoft | 1:c49f6eb130b4 | 10 | SW1.mode(PullUp); |
jksoft | 1:c49f6eb130b4 | 11 | SW2.mode(PullUp); |
jksoft | 1:c49f6eb130b4 | 12 | while(1) |
jksoft | 1:c49f6eb130b4 | 13 | { |
jksoft | 1:c49f6eb130b4 | 14 | if( SW1 == 0 ) |
jksoft | 1:c49f6eb130b4 | 15 | { |
jksoft | 1:c49f6eb130b4 | 16 | MOTOR_A = 50; |
jksoft | 1:c49f6eb130b4 | 17 | MOTOR_B = 50; |
jksoft | 1:c49f6eb130b4 | 18 | } |
jksoft | 1:c49f6eb130b4 | 19 | else if( SW2 == 0 ) |
jksoft | 1:c49f6eb130b4 | 20 | { |
jksoft | 1:c49f6eb130b4 | 21 | MOTOR_A = -50; |
jksoft | 1:c49f6eb130b4 | 22 | MOTOR_B = -50; |
jksoft | 1:c49f6eb130b4 | 23 | } |
jksoft | 1:c49f6eb130b4 | 24 | else |
jksoft | 1:c49f6eb130b4 | 25 | { |
jksoft | 1:c49f6eb130b4 | 26 | MOTOR_A = 0; |
jksoft | 1:c49f6eb130b4 | 27 | MOTOR_B = 0; |
jksoft | 1:c49f6eb130b4 | 28 | } |
jksoft | 0:effe57895c37 | 29 | } |
jksoft | 0:effe57895c37 | 30 | } |