手動機 ヌクレオ用のプログラムです

Dependencies:   mbed

Fork of F3RC_syudou_slave by F3RC1班

Revision:
5:72e5a850678a
Parent:
4:5ba58456c3ee
--- a/main.cpp	Fri Aug 25 12:23:46 2017 +0000
+++ b/main.cpp	Thu Sep 14 01:20:53 2017 +0000
@@ -2,8 +2,8 @@
 
 Serial pc(USBTX,USBRX);
 BusIn in(PA_7,PA_6,PA_5,PA_4);
-PwmOut moter_1(PB_14);
-PwmOut moter_2(PB_15);
+PwmOut motor_1(PB_14);
+PwmOut motor_2(PB_15);
 DigitalOut cyli_1(PB_5);
 DigitalOut cyli_2(PB_3);
 DigitalOut cyli_3(PA_10);
@@ -15,24 +15,24 @@
 int num;
 
 //モーターの出力の設定
-double moter_power = 0.7;
+double motor_power = 0.6;
 
 
 //腕上昇下降の関数
 void up()
 {
-    moter_1=moter_power;
-    moter_2=0;
+    motor_1=0;
+    motor_2=motor_power;
 }
 void down()
 {
-    moter_1=0;
-    moter_2=moter_power;
+    motor_1=motor_power;
+    motor_2=0;
 }
 void stop()
 {
-    moter_1=0;
-    moter_2=0;
+    motor_1=0;
+    motor_2=0;
 }
 //フラグ
 int up_flag=1;
@@ -58,7 +58,8 @@
 }
 int main()
 {
-
+motor_1.period_us(100);
+motor_2.period_us(100);
 
 //フォトインタラプタ1
     photo_1.rise(&photo_1_rise);
@@ -73,32 +74,36 @@
 
 
 //腕1 上昇下降
-        if(num == 1 && up_flag==1) {//上昇
+        if(num == 1 && up_flag==1) {//フラグ1で上昇
             up();
-        } else if(num == 2 && down_flag==1) {//下降
+            num=1;
+            pc.printf("up\n");
+        } else if(num == 2 && down_flag==1) {//フラグ1で下降
             down();
-        } else {
+            num=2;
+            pc.printf("down\n");
+        } else {//止まる
             stop();
         }
 
 //腕1 開閉
-        if(num == 3) {
+        if(num == 3) {//開く
             cyli_1=1;
-        } else if(num == 4) {
+        } else if(num == 4) {//閉じる
             cyli_1=0;
         }
 
 //腕2 上昇下降
-        if(num == 5) {
+        if(num == 5) {//上昇
+            cyli_2=0;
+        } else if(num == 6) {//下降
             cyli_2=1;
-        } else if(num == 6) {
-            cyli_2=0;
         }
 
 //腕2 開閉
-        if(num == 7) {
+        if(num == 7) {//開く
             cyli_3=1;
-        } else if(num == 8) {
+        } else if(num == 8) {//閉じる
             cyli_3=0;
         }
         pc.printf("%d\n\r",num);