2021 NHK B

Revision:
9:252dd0bc8f93
Parent:
8:f276fe03c43d
Child:
10:30d3eb684016
--- a/ikarashiSV.cpp	Sat Oct 23 03:38:23 2021 +0000
+++ b/ikarashiSV.cpp	Sat Oct 23 03:44:50 2021 +0000
@@ -69,12 +69,12 @@
 void ikarashiSV2::solenoid(int _state2)
 {
     switch(_state2) {
-        case 1:
+        case 1://push
             port_e = 0;
             port_f = 1;
             solenoid_status2 = 1;
             break;
-        case 0:
+        case 0://pull
             port_e = 1;
             port_f = 0;
             solenoid_status2 = 0;
@@ -96,29 +96,40 @@
 #include "mbed.h"
 #include "ikarashiSV.h"
 
+DigitalOut led1(LED1);
 Serial pc(USBTX, USBRX,115200);
 
-ikarashiSV slv(PC_7,PB_10,PB_4,PB_5);
+ikarashiSV slv1(PB_5,PB_4,PB_10,PA_5);
+ikarashiSV2 slv2(PB_9,PB_8);
+Servo servo(PB_14);
+Ticker timer;
 
 //ボタンを押したときor離したときを読み取る定義の仕方
 InterruptIn button(USER_BUTTON);
 
+int check = 0;
+
 void add()
 {
-    slv.add_state();
+    if(check >= 1) {
+        slv1.add_state();
+    }
+    check++;
 }
 
 int main()
 {
     int val;
+    timer.attach(&add, 2);
     while(1) {
-        button.fall(&add);
-        val = slv.state_show();
-        pc.printf("\t\tstate : %d",val);
-        if(val >= 1) {
-            slv.solenoid(val%3);
-        }
-        slv.solenoid_show();
+        val = slv1.state_show();
+        pc.printf("state : %d",val);
+        pc.printf("\tservo : %0.2f\t",servo.read());
+        slv1.solenoid_show();
+        slv2.solenoid_show();
+        printf("\n\r");
+        slv1.solenoid(val%3);
+        slv2.solenoid(val%2);
     }
 }