かいださん

Dependencies:   mbed

Fork of 2016_Spring_kaida by 新部内対抗5班

Files at this revision

API Documentation at this revision

Comitter:
abcdefgh
Date:
Fri Jun 10 17:29:55 2016 +0000
Parent:
17:efe67bbb927e
Commit message:
2016/06/10

Changed in this revision

KaidaKari.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/KaidaKari.cpp	Fri Jun 10 06:05:29 2016 +0000
+++ b/KaidaKari.cpp	Fri Jun 10 17:29:55 2016 +0000
@@ -8,24 +8,25 @@
 int RSX,RSY,LSX,LSY,BSU,BSL;
 //これより下に関数外に書く要素を記入する
 double flag;
+
 //MD1
-PwmOut motorRightOne (p23);
-PwmOut motorRightTwo (p24);
+
+PwmOut motorRightOne (p26);
+PwmOut motorRightTwo (p25);
 
 //MD2
-PwmOut motorLeftOne (p21);
-PwmOut motorLeftTwo (p22);
+PwmOut motorLeftOne (p23);
+PwmOut motorLeftTwo (p24);
 
 //MD3 Arm1
-PwmOut armRight(p26);
-DigitalOut armThree (p30);
-DigitalOut armFour (p29);
+PwmOut armRight(p22);
+DigitalOut armOne (p29);
+DigitalOut armTwo (p30);
 
 //MD4 Arm2
-PwmOut armLeft(p25);
-DigitalOut armOne (p6);
-DigitalOut armTwo (p5);
-
+PwmOut armLeft(p21);
+DigitalOut armThree (p19);
+DigitalOut armFour (p20);
 
 /*
 
@@ -93,35 +94,44 @@
      */
 
 //motor
-    if((ButtonState >> BUTTONPS)&1 == 1){
+
+    if((ButtonState >> BUTTONSTART)&1 == 1) {
         flag = 0;
-    }else if((ButtonState >> BUTTONSTART)&1 == 1) {
+    } else if((ButtonState >> BUTTONR2)&1 == 1) {
         flag += 0.05;
-    } else if((ButtonState >> BUTTONSELECT)&1 == 1) {
+        wait(0.1);
+    } else if((ButtonState >> BUTTONL2)&1 == 1) {
         flag -= 0.05;
+        wait(0.1);
     }
-    
+    if(flag >= 1.0) {
+        flag = 1.0;
+    }
+    if(flag <= -0.5) {
+        flag = 0.5;
+    }
+
     if(LSY>140 && ((ButtonState >> BUTTONLANALOG)&1) == 1) {
-         motorRightOne = 0.8;
+        motorRightOne = 0.8;
         motorRightTwo = 0;
         motorLeftOne = 0.8;
         motorLeftTwo = 0;
-    }else if(LSY<110 && ((ButtonState >> BUTTONLANALOG)&1) == 1) {
-         motorRightOne = 0;
+    } else if(LSY<110 && ((ButtonState >> BUTTONLANALOG)&1) == 1) {
+        motorRightOne = 0;
         motorRightTwo = 0.8;
         motorLeftOne = 0;
-        motorLeftTwo = 0.8;        
-    }else if(  LSY > 140 ) { //forward
-        motorRightOne = 0.4 + flag;
+        motorLeftTwo = 0.8;
+    } else if(  LSY > 140 ) { //forward
+        motorRightOne = 0.6 + flag;
         motorRightTwo = 0;
-        motorLeftOne = 0.4 + flag;
+        motorLeftOne = 0.6 + flag;
         motorLeftTwo = 0;
 
     } else if( LSY < 110 ) { //back
         motorRightOne = 0;
-        motorRightTwo = 0.4 + flag;
+        motorRightTwo = 0.6 + flag;
         motorLeftOne = 0;
-        motorLeftTwo = 0.4 + flag;
+        motorLeftTwo = 0.6 + flag;
     } else { //stop
         motorRightOne = 0;
         motorRightTwo = 0;
@@ -130,25 +140,25 @@
     }
 
     if(( ButtonState >> BUTTONR1)&1 == 1) {
-        motorRightOne = 0;
-        motorRightTwo = 0.4 + flag;
-        motorLeftOne = 0.4 + flag;
-        motorLeftTwo = 0;
+        motorRightOne = 0.5 + flag;
+        motorRightTwo = 0;
+        motorLeftOne = 0;
+        motorLeftTwo = 0.5 + flag;
     }
     if(( ButtonState >> BUTTONL1)&1 == 1) {
-        motorRightOne = 0.4 + flag;
-        motorRightTwo = 0;
-        motorLeftOne = 0;
-        motorLeftTwo = 0.4 + flag;
+        motorRightOne = 0;
+        motorRightTwo = 0.5 + flag;
+        motorLeftOne = 0.5 + flag;
+        motorLeftTwo = 0;
     }
 
 //arm
 
-    if(  (ButtonState >> BUTTONUP)&1 == 1 ) {
+    if(  (ButtonState >> BUTTONDOWN)&1 == 1 ) {
         armThree = 0;
         armFour = 1;
-        armLeft = 0.4;
-    } else if( (ButtonState >> BUTTONDOWN)&1 == 1 ) {
+        armLeft = 0.8;
+    } else if( (ButtonState >> BUTTONUP)&1 == 1 ) {
         armThree = 1;
         armFour = 0;
         armLeft = 0.4;
@@ -159,11 +169,11 @@
 
     }
 
-    if((ButtonState >> BUTTONSQUARE)&1 == 1) {
+    if((ButtonState >> BUTTONTRIANGEL)&1 == 1) {
         armOne = 1;
         armTwo = 0;
         armRight = 0.4;
-    } else if((ButtonState >> BUTTONCIRCLE)&1 == 1) {
+    } else if((ButtonState >> BUTTONCROSS)&1 == 1) {
         armOne = 0;
         armTwo = 1;
         armRight = 0.4;
@@ -172,7 +182,6 @@
         armTwo = 0;
         armRight = 0;
 
-printf("%f ",flag);
 
         /*
         With oen if, put both arms and legs.