手動機アーム、ヌクレオ基盤のプログラムです(9/4)

Dependencies:   RcServo mbed

Fork of a_SPI_slave_arm_shudouki by F^3 RC 2班

Files at this revision

API Documentation at this revision

Comitter:
yoka06
Date:
Mon Sep 04 12:39:59 2017 +0000
Parent:
3:f200ae8fea88
Commit message:
a

Changed in this revision

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
--- a/main.cpp	Fri Aug 25 07:55:59 2017 +0000
+++ b/main.cpp	Mon Sep 04 12:39:59 2017 +0000
@@ -3,33 +3,27 @@
 #include "motor_1.h"
 #include "motor_2.h"
 
-
 int a,b,c,d,e,f,g,h;
-
-Serial pc(USBTX,USBRX);
+//Serial pc(USBTX,USBRX);
 SPISlave spi(PA_7,PA_6,PA_5,PA_4);
 
 RcServo sA(PB_0,500,2400,180);       //PwmOutのpin,minpulsewidth,maxpulsewidth,motionrange
-RcServo sB(PA_9,500,2100,180);
+RcServo sB(PA_9,500,2400,180);
 RcServo sC(PA_10,500,2100,180);
 RcServo sD(PA_11,500,3000,180);
 RcServo sE(PA_2,500,2400,180);
 RcServo sF(PA_3,500,3000,180);
 RcServo sG(PA_8,500,2400,180);
-M1 mH(PB_7,PB_6);     //pwm*2
-
-
-
-
+M2 mH(PB_6,PA_0,PA_1);     //pwm*1,digital*2
 
 int main()
 {
-
-    spi.format(16,3);
+    spi.format(8,3);
     spi.frequency(1000000);
 
+
     while(1) {
-        if (spi.receive()) {
+        if(spi.receive()) {
 
             a=spi.read() & 0b1;
             b=(spi.read() & 0b10)>>1;
@@ -39,88 +33,93 @@
             f=(spi.read() & 0b100000)>>5;
             g=(spi.read() & 0b1000000)>>6;
             h=(spi.read() & 0b10000000)>>7;
+            //pc.printf("a:%d\t b:%d\t c:%d\t d:%d\t e:%d\t f:%d\t g:%d\t h:%d\t send:%d\r\n",a,b,c,d,e,f,g,h,spi.read());
+        }
 
 
+        if(a==1) {
+            //if((ButtonState >> BUTTONUP)&1 == 1) { // ▲で燃料用アーム展開
+            sD.set_deg(80);
+            wait(0.7);
+            sA.set_deg(118);
+            wait(1.2);
+            sB.set_deg(0);
+            sC.set_deg(180);
+
+        }
+
 
 
-            if(a==1) {
-                // if((ButtonState >> BUTTONUP)&1 == 1) { // ▲で燃料用アーム展開
-                sD.set_deg(90);
-                wait(0.7);
-                sA.set_deg(62);
-                wait(0.7);
-                sB.set_deg(180);
-                sC.set_deg(0);
-            }
+        if(b==1) {
+            //if((ButtonState >> BUTTONTRIANGEL)&1 == 1) { // △で燃料回収
+            sB.set_deg(180);
+            sC.set_deg(0);
+            wait(0.7);
+            sA.set_deg(28);
+            wait(0.7);
+            sD.set_deg(0);
+            sE.set_deg(120);
 
 
 
-            if(b==1) {
-                //  if((ButtonState >> BUTTONTRIANGEL)&1 == 1) { // △で燃料回収
-                sB.set_deg(0);
-                sC.set_deg(180);
-                wait(0.7);
-                sA.set_deg(152);
-                wait(0.7);
-                sD.set_deg(180);
-                sE.set_deg(120);
+        }
 
-            }
+        if(c==1) {
+            //if((ButtonState >> BUTTONLEFT)&1 == 1) { // ◀で燃料掃き出し
+            mH.move(1);
+            wait(1.2);
+            mH.move(0);
+
+        }
 
-            if(c==1) {
-                // if((ButtonState >> BUTTONLEFT)&1 == 1) { // ◀で燃料掃き出し
-                mH.move(0.5);
-                wait(1);
-                mH.move(0);
-
-            }
+        if(d==1) {
+            //if((ButtonState >> BUTTONCIRCLE)&1 == 1) { // 〇でタンク回収
+            sA.set_deg(118);
+            sE.set_deg(30);
+            wait(0.7);
+            sD.set_deg(180);
+            wait(0.7);
+            sE.set_deg(120);
+            wait(0.7);
+            sD.set_deg(80);
+            wait(0.7);
+            sE.set_deg(90);
+            sA.set_deg(27);
 
-            if(d==1) {
-                // if((ButtonState >> BUTTONCIRCLE)&1 == 1) { // 〇でタンク回収
-                sA.set_deg(90);
-                sE.set_deg(90);
-                wait(0.7);
-                sD.set_deg(0);
-                wait(0.7);
-                sE.set_deg(120);
-                wait(0.7);
-                sD.set_deg(90);
-                wait(0.7);
-                sE.set_deg(90);
-                sA.set_deg(158);
+
+
+        }
 
-            }
-
-            if(e==1) {
-                // if((ButtonState >> BUTTONRIGHT)&1 == 1) { // ‣でタンク掃き出し
-                mH.move(-0.5);
-                wait(1);
-                mH.move(0);
-            }
+        if(e==1) {
+            //if((ButtonState >> BUTTONRIGHT)&1 == 1) { // ‣でタンク掃き出し
+            mH.move(-1);
+            wait(1.2);
+            mH.move(0);
+        }
 
-            if(f==1) {
-                //  if((ButtonState >> BUTTONDOWN)&1 == 1) { // ▼で待機
-                sF.set_deg(180);
-                sG.set_deg(120);
-                wait(0.7);
-                sA.set_deg(180);
-                wait(0.7);
-                sD.set_deg(0);
+        if(f==1) {
+            //if((ButtonState >> BUTTONDOWN)&1 == 1) { // ▼で待機
+
+            sF.set_deg(0);
+            sG.set_deg(100);
+            sE.set_deg(5);
+            sD.set_deg(180);
+        }
 
-            }
-            if(g==1) {
-                // if((ButtonState >> BUTTONCROSS)&1 == 1) { // ×でサンプル受け取り
-                sG.set_deg(90);
-                wait(0.7);
-                sF.set_deg(90);
+        if(g==1) {
+            //if((ButtonState >> BUTTONCROSS)&1 == 1) { // ×でサンプル受け取り
+            sG.set_deg(30);
+            wait(0.7);
+            sF.set_deg(87);
+
+        }
 
-            }
-            if(h==1) {
-                //  if((ButtonState >> BUTTONSQUARE)&1 == 1) { // □でサンプル設置
-                sG.set_deg(120);
-            }
+        if(h==1) {
+            //if((ButtonState >> BUTTONSQUARE)&1 == 1) { // □でサンプル設置
+            sG.set_deg(120);
         }
-        
-        pc.printf("a:%d\t b:%d\t c:%d\t d:%d\t e:%d\t f:%d\t g:%d\t h:%d\t send:%d\n",a,b,c,d,e,f,g,h,spi.read());
+
     }
+
 }
+
--- a/mbed.bld	Fri Aug 25 07:55:59 2017 +0000
+++ b/mbed.bld	Mon Sep 04 12:39:59 2017 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725
\ No newline at end of file