悠登 山本 / Mbed 2 deprecated CanSatB2019_main_Class導入前

Dependencies:   mbed CameraUS015sb612-3

Files at this revision

API Documentation at this revision

Comitter:
YUPPY
Date:
Fri Nov 08 19:48:16 2019 +0000
Parent:
2:e2b803e3bcbc
Child:
4:1354e56c7dd3
Commit message:
main

Changed in this revision

TB6612.h 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TB6612.h	Fri Nov 08 19:48:16 2019 +0000
@@ -0,0 +1,30 @@
+/**
+ * Motor Driver TB6612 Control Library
+ *
+ * -- TB6612 is a device of the rohm. 
+ *
+ * Copyright (C) 2012 Junichi Katsu (JKSOFT) 
+ */
+ 
+#ifndef MBED_TB6612_H
+#define MBED_TB6612_H
+ 
+#include "mbed.h"
+ 
+class TB6612 {
+public:
+    TB6612(PinName pwm, PinName fwd, PinName rev);
+    void speed(int speed);
+    void move(int speed , int time);
+    void operator= ( int value )
+    {
+        speed(value);
+    }
+    
+protected:
+    PwmOut _pwm;
+    DigitalOut _fwd;
+    DigitalOut _rev;
+};
+ 
+#endif
\ No newline at end of file
--- a/main.cpp	Fri Nov 08 16:16:43 2019 +0000
+++ b/main.cpp	Fri Nov 08 19:48:16 2019 +0000
@@ -2,6 +2,7 @@
 #include "mbed.h"       //mbed
 #include "getGPS.h"         //GPS
 #include "math.h"         //GPS
+#include "TB6612.h"      //motorDriver
 #include "XBee.h"        //XBee
 #include <SoftwareSerial.h>   //カメラ
 #include <SD.h>//SDカード
@@ -20,8 +21,8 @@
 DigitalOut led(LED1);     
 Serial pc(USBTX, USBRX); // tx, rx  焦電センサ↑
 Serial pc (p9);     //カメラ
-//Motor motor1(p22, p16, p17, 1); // pwm, fwd, rev, can brake     モーター
-//Motor motor2(p22, p19, p20, 1); // pwm, fwd, rev, can brake
+TB6612 left(p25,p17,p16);
+TB6612 right(p26,p19,p18);
 
 int main() {            //FET
     FET = 0;
@@ -116,38 +117,17 @@
         return 0;          //注意!void()に変えること.このままだとここで終わる
      }
       
-
-void motorForwardR(void);
-void motorStopR(void);
-void motorReverseR(void);
-void motorForwardL(void);
-void motorStopL(void);
-void motorReverseL(void);
-LocalFileSystem local(“local”);               // Create the local filesystem under the name “local”   データ保存
-float culculate_distance_3(float a,float b);
-
-   motorStopR();
-   motorStopL();
-   wait(20);     //確認用//デフォ20秒
-//    FILE *fp = fopen(“/local/gps.txt”, “w”);  // Open “gps.txt” on the local file system for writing
-         motorSpeedR.period_ms(4);              //モーター調節
-         motorSpeedR = 0.655;
-         motorSpeedL.period_ms(4);              //モーター調節
-motorSpeedL = 0.755;
- motorForwardL(); //車体を時計回りに3秒回転
-   motorReverseR();
-   wait(1.6);
-   motorStopR();
-   motorStopL();
-   wait(1);
-   motorReverseL(); //車体を反時計回りに3秒回転
-   motorForwardR();
-   wait(1.6);
-   motorStopR();
-   motorStopL();
-   wait(1);
-   printf(“compass carriblation\r\n”); //キャリブレーション終了
-//float mcn1,mcn2;
+int main() {
+    while(1) {
+        left = 100; //左モーター100%
+        right = 100;//右モーター100%
+        wait(1.0);
+        left = 30;//左30%
+        right = 30;//右30%
+        wait(1.0);
+        printf("OK");
+    }
+}
 
 if(distance<2000){
     motorStopR();