移動系の統合試験用プログラムです。
Dependencies: mbed TB6612FNG HMC6352 getGPS
Move.h@2:0c73afb20925, 2021-10-24 (annotated)
- Committer:
- ushiroji
- Date:
- Sun Oct 24 14:46:02 2021 +0000
- Revision:
- 2:0c73afb20925
- Child:
- 4:135619de1646
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ushiroji | 2:0c73afb20925 | 1 | #include "TB6612.h" |
ushiroji | 2:0c73afb20925 | 2 | |
ushiroji | 2:0c73afb20925 | 3 | TB6612 motor_a(D10,D6,D7); //モータA制御用(pwma,ain1,ain2) |
ushiroji | 2:0c73afb20925 | 4 | TB6612 motor_b(D11,D8,D9); //モータB制御用(pwmb,bin1,bin2) |
ushiroji | 2:0c73afb20925 | 5 | |
ushiroji | 2:0c73afb20925 | 6 | void Move(char input_data, float motor_speed) { |
ushiroji | 2:0c73afb20925 | 7 | switch (input_data) { |
ushiroji | 2:0c73afb20925 | 8 | case '1': // 停止 |
ushiroji | 2:0c73afb20925 | 9 | motor_a = 0; |
ushiroji | 2:0c73afb20925 | 10 | motor_b = 0; |
ushiroji | 2:0c73afb20925 | 11 | break; |
ushiroji | 2:0c73afb20925 | 12 | case '2': // 前進 |
ushiroji | 2:0c73afb20925 | 13 | motor_a = motor_speed; |
ushiroji | 2:0c73afb20925 | 14 | motor_b = motor_speed; |
ushiroji | 2:0c73afb20925 | 15 | break; |
ushiroji | 2:0c73afb20925 | 16 | case '3': // 後退 |
ushiroji | 2:0c73afb20925 | 17 | motor_a = -motor_speed; |
ushiroji | 2:0c73afb20925 | 18 | motor_b = -motor_speed; |
ushiroji | 2:0c73afb20925 | 19 | break; |
ushiroji | 2:0c73afb20925 | 20 | case '4': // 時計回りに回転 |
ushiroji | 2:0c73afb20925 | 21 | motor_a = motor_speed; |
ushiroji | 2:0c73afb20925 | 22 | motor_b = -motor_speed; |
ushiroji | 2:0c73afb20925 | 23 | break; |
ushiroji | 2:0c73afb20925 | 24 | case '5': // 反時計回りに回転 |
ushiroji | 2:0c73afb20925 | 25 | motor_a = -motor_speed; |
ushiroji | 2:0c73afb20925 | 26 | motor_b = motor_speed; |
ushiroji | 2:0c73afb20925 | 27 | break; |
ushiroji | 2:0c73afb20925 | 28 | case '6': // Aのみ正転 |
ushiroji | 2:0c73afb20925 | 29 | motor_a = motor_speed; |
ushiroji | 2:0c73afb20925 | 30 | break; |
ushiroji | 2:0c73afb20925 | 31 | case '7': // Bのみ正転 |
ushiroji | 2:0c73afb20925 | 32 | motor_b = motor_speed; |
ushiroji | 2:0c73afb20925 | 33 | break; |
ushiroji | 2:0c73afb20925 | 34 | case '8': // Aのみ逆転 |
ushiroji | 2:0c73afb20925 | 35 | motor_a = -motor_speed; |
ushiroji | 2:0c73afb20925 | 36 | break; |
ushiroji | 2:0c73afb20925 | 37 | case '9': // Bのみ逆転 |
ushiroji | 2:0c73afb20925 | 38 | motor_b = -motor_speed; |
ushiroji | 2:0c73afb20925 | 39 | break; |
ushiroji | 2:0c73afb20925 | 40 | default: |
ushiroji | 2:0c73afb20925 | 41 | // エラーメッセージを返す |
ushiroji | 2:0c73afb20925 | 42 | break; |
ushiroji | 2:0c73afb20925 | 43 | } |
ushiroji | 2:0c73afb20925 | 44 | pc.printf("%d", input_data); |
ushiroji | 2:0c73afb20925 | 45 | } |