2021 nhk A team

Dependencies:   mbed QEI led beep softPWM Servo_softpwm IR2302 lpf

Revision:
30:00a513858a44
Parent:
29:3bd99866801f
Child:
31:ce079259f559
--- a/main.cpp	Sat Oct 30 03:14:36 2021 +0000
+++ b/main.cpp	Sat Oct 30 07:56:14 2021 +0000
@@ -15,7 +15,7 @@
 
 Serial pc(USBTX,USBRX,115200);
 
-//Beep buzzer(BEEP);
+Beep buzzer(BEEP);
 JY901 jy(SDA, SCL);
 //DigitalOut stop(STOP);
 
@@ -29,7 +29,8 @@
 Timer setWait,nextWait,jumpWait;
 AnalogIn ph[3] = {PHOTO1,PHOTO2,PHOTO3};
 DigitalOut light[3] = {ROPE1,ROPE2,ROPE3};
-DigitalIn b(USER_BUTTON);
+DigitalIn ub(USER_BUTTON);
+DigitalIn ab(PA_15);
 
 int main()
 {
@@ -46,7 +47,8 @@
     float phI[3] = {0};//フォトインタラプタ
     bool rope = 0;
 
-    bool firstFlag = 1;//1
+    bool setFlag   = 1;//1
+    bool firstFlag = 0;//0
     bool secondFlag= 0;//0
     bool thirdFlag = 0;//0
     bool swingFlag = 1;//1
@@ -62,12 +64,11 @@
     for(int i=0;i < 3; i++)servo[i].calibrate(0.00095, 90);
     servoAngle[0] = 0.2;
     servoAngle[1] = 0.2;
-    servoAngle[2] = 0.82;
+    servoAngle[2] = 0.8;
     for(i=0;i<3;i++) servo[i].write(servoAngle[i]);
     for(i=0; i<3; i++) light[i] = true;
     
-
-    wait(5);
+    ub.mode(PullDown);
     
     while(1) 
     {
@@ -102,6 +103,23 @@
         
 //処理部
 
+    //セッティング
+        if(setFlag)
+        {
+            if(!ub && !ab) motor=0.25;
+            else if(ab && ub)  motor=-0.25;
+            else if(!ab && ub) motor=0;
+            else if(!ub && ab)
+            {
+                setFlag = 0;
+                firstFlag = 1;
+                buzzer.beep(3000,1.0);
+                wait(5);
+                buzzer.nobeep();
+            }
+
+        }
+
     //加速1段目
         if(firstFlag)
         {
@@ -271,17 +289,17 @@
       
 //表示系
 //        pc.printf("%.2f,%.2f,%.2f",angle[0],angle[1],angle[2]);
-//        pc.printf("%.2f,%.2f,%.2f,",servoAngle[0],servoAngle[1],servoAngle[2]);
-//        pc.printf("%.4f,",motor);
+        pc.printf("%.2f,%.2f,%.2f,",servoAngle[0],servoAngle[1],servoAngle[2]);
+        pc.printf("%.4f,",motor);
 //        pc.printf("%.2f,%.2f,",abac[1],abac[2]);
 //        pc.printf("%.2f,%.2f,",lpfY,lpfZ);
 //        pc.printf("%d,",nowPalse);
-//        pc.printf("%d,",catchFlag);
+        pc.printf("%d,",setFlag);
 //        pc.printf("%d,",resetFlag);
 //        pc.printf("%.2f,",lpfM);
 //        pc.printf("%.3f,%.3f,%.3f,",phI[0],phI[1],phI[2]);
 //        pc.printf("%d,",k);
-//        pc.printf("\r\n");
+        pc.printf("\r\n");
 
     }
 }