回避用のプログラムです。

Dependencies:   mbed TB6612FNG US015

Committer:
ushiroji
Date:
Thu Oct 21 12:10:23 2021 +0000
Revision:
0:92fbe3130656
test;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ushiroji 0:92fbe3130656 1 #include "TB6612.h"
ushiroji 0:92fbe3130656 2
ushiroji 0:92fbe3130656 3 TB6612 motor_a(D10,D6,D7); //モータA制御用(pwma,ain1,ain2)
ushiroji 0:92fbe3130656 4 TB6612 motor_b(D11,D8,D9); //モータB制御用(pwmb,bin1,bin2)
ushiroji 0:92fbe3130656 5 Serial pc(USBTX, USBRX);
ushiroji 0:92fbe3130656 6
ushiroji 0:92fbe3130656 7 void MotorDriver(char input_data, float motor_speed) {
ushiroji 0:92fbe3130656 8 switch (input_data) {
ushiroji 0:92fbe3130656 9 case '1': // 停止
ushiroji 0:92fbe3130656 10 motor_a = 0;
ushiroji 0:92fbe3130656 11 motor_b = 0;
ushiroji 0:92fbe3130656 12 break;
ushiroji 0:92fbe3130656 13 case '2': // 前進
ushiroji 0:92fbe3130656 14 motor_a = motor_speed;
ushiroji 0:92fbe3130656 15 motor_b = motor_speed;
ushiroji 0:92fbe3130656 16 break;
ushiroji 0:92fbe3130656 17 case '3': // 後退
ushiroji 0:92fbe3130656 18 motor_a = -motor_speed;
ushiroji 0:92fbe3130656 19 motor_b = -motor_speed;
ushiroji 0:92fbe3130656 20 break;
ushiroji 0:92fbe3130656 21 case '4': // 時計回りに回転
ushiroji 0:92fbe3130656 22 motor_a = motor_speed;
ushiroji 0:92fbe3130656 23 motor_b = -motor_speed;
ushiroji 0:92fbe3130656 24 break;
ushiroji 0:92fbe3130656 25 case '5': // 反時計回りに回転
ushiroji 0:92fbe3130656 26 motor_a = -motor_speed;
ushiroji 0:92fbe3130656 27 motor_b = motor_speed;
ushiroji 0:92fbe3130656 28 break;
ushiroji 0:92fbe3130656 29 case '6': // Aのみ正転
ushiroji 0:92fbe3130656 30 motor_a = motor_speed;
ushiroji 0:92fbe3130656 31 break;
ushiroji 0:92fbe3130656 32 case '7': // Bのみ正転
ushiroji 0:92fbe3130656 33 motor_b = motor_speed;
ushiroji 0:92fbe3130656 34 break;
ushiroji 0:92fbe3130656 35 case '8': // Aのみ逆転
ushiroji 0:92fbe3130656 36 motor_a = -motor_speed;
ushiroji 0:92fbe3130656 37 break;
ushiroji 0:92fbe3130656 38 case '9': // Bのみ逆転
ushiroji 0:92fbe3130656 39 motor_b = -motor_speed;
ushiroji 0:92fbe3130656 40 break;
ushiroji 0:92fbe3130656 41 default:
ushiroji 0:92fbe3130656 42 // エラーメッセージを返す
ushiroji 0:92fbe3130656 43 break;
ushiroji 0:92fbe3130656 44 }
ushiroji 0:92fbe3130656 45 pc.printf("%d", input_data);
ushiroji 0:92fbe3130656 46 }