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

Dependencies:   mbed TB6612FNG US015

Files at this revision

API Documentation at this revision

Comitter:
ushiroji
Date:
Thu Oct 21 12:10:23 2021 +0000
Commit message:
test;

Changed in this revision

FrontGet.h Show annotated file Show diff for this revision Revisions of this file
Move.h Show annotated file Show diff for this revision Revisions of this file
TB6612FNG.lib Show annotated file Show diff for this revision Revisions of this file
US015.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 92fbe3130656 FrontGet.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FrontGet.h	Thu Oct 21 12:10:23 2021 +0000
@@ -0,0 +1,15 @@
+#include "us015.h"
+
+US015 hs(D2, D3);
+DigitalOut Ultra(D2);
+Serial pc(USBTX,USBRX); 
+
+int FrontGet() {
+        Ultra = 1;  //超音波on
+        hs.TrigerOut();
+        wait(1);
+        distance = hs.GetDistance();
+        pc.printf("distance=%d\r\n", distance);  //距離出力
+        Ultra=0;//超音波off
+        return distance;
+}
\ No newline at end of file
diff -r 000000000000 -r 92fbe3130656 Move.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Move.h	Thu Oct 21 12:10:23 2021 +0000
@@ -0,0 +1,46 @@
+#include "TB6612.h"
+
+TB6612 motor_a(D10,D6,D7);  //モータA制御用(pwma,ain1,ain2)
+TB6612 motor_b(D11,D8,D9);  //モータB制御用(pwmb,bin1,bin2)
+Serial pc(USBTX, USBRX);
+
+void MotorDriver(char input_data, float motor_speed) {
+    switch (input_data) {
+        case '1':  // 停止
+            motor_a = 0;
+            motor_b = 0;
+            break;
+        case '2':  // 前進
+            motor_a = motor_speed;
+            motor_b = motor_speed;
+            break;
+        case '3':  // 後退
+            motor_a = -motor_speed;
+            motor_b = -motor_speed;
+            break;
+        case '4':  // 時計回りに回転
+            motor_a = motor_speed;
+            motor_b = -motor_speed;
+            break;
+        case '5':  // 反時計回りに回転
+            motor_a = -motor_speed;
+            motor_b = motor_speed;
+            break;
+        case '6':  // Aのみ正転
+            motor_a = motor_speed;
+            break;
+        case '7':  // Bのみ正転
+            motor_b = motor_speed;
+            break;
+        case '8':  // Aのみ逆転
+            motor_a = -motor_speed;
+            break;
+        case '9':  // Bのみ逆転
+            motor_b = -motor_speed;
+            break;
+        default:
+            // エラーメッセージを返す
+            break;
+    }
+    pc.printf("%d", input_data);
+}
\ No newline at end of file
diff -r 000000000000 -r 92fbe3130656 TB6612FNG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TB6612FNG.lib	Thu Oct 21 12:10:23 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/jksoft/code/TB6612FNG/#95d5e9ee8c15
diff -r 000000000000 -r 92fbe3130656 US015.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/US015.lib	Thu Oct 21 12:10:23 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/firlight1034/code/US015/#d377daf497e2
diff -r 000000000000 -r 92fbe3130656 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 21 12:10:23 2021 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+#include "Move.h"
+
+int main() 
+{
+    int distance;
+    while(1) {
+        if(distance <= 200) {
+            MotorDriver(4, 0.5);
+            pc.printf("alart");
+        }
+        else {
+            MotorDriver(2, 1);
+            pc.printf("Start Move");
+            break;
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 92fbe3130656 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 21 12:10:23 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file