Junichi Katsu
/
JBB_Motor_test
It is a motor driver test program Jksoft Blue mbed Board. Jksoft Blue mbed Boardのモータードライバテストプログラムです。
Revision 1:c49f6eb130b4, committed 2014-05-12
- Comitter:
- jksoft
- Date:
- Mon May 12 14:11:06 2014 +0000
- Parent:
- 0:effe57895c37
- Commit message:
- 2nd
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r effe57895c37 -r c49f6eb130b4 main.cpp --- a/main.cpp Mon May 12 10:56:42 2014 +0000 +++ b/main.cpp Mon May 12 14:11:06 2014 +0000 @@ -1,15 +1,30 @@ #include "mbed.h" +#include "TB6612.h" -DigitalOut myled(LED1); -TB6612 motor_1(p21,p19,p20); // PWM IN1 IN2 -DigitalIn sw_1(p25); -DigitalIn sw_2(p26); +TB6612 MOTOR_A(p21,p19,p20); // PWM IN1 IN2 +TB6612 MOTOR_B(p22,p29,p30); // PWM IN1 IN2 +DigitalIn SW1(p25); +DigitalIn SW2(p26); int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); + SW1.mode(PullUp); + SW2.mode(PullUp); + while(1) + { + if( SW1 == 0 ) + { + MOTOR_A = 50; + MOTOR_B = 50; + } + else if( SW2 == 0 ) + { + MOTOR_A = -50; + MOTOR_B = -50; + } + else + { + MOTOR_A = 0; + MOTOR_B = 0; + } } }