yuto kawamura / Mbed 2 deprecated MR2_2n_1_saku

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kageyuta
Date:
Sat Apr 27 05:41:33 2019 +0000
Parent:
1:86c4c38abe40
Child:
3:7a608fbd3bcd
Commit message:
Kawamura and Okamoto are slaves.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
pin.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Apr 27 04:28:33 2019 +0000
+++ b/main.cpp	Sat Apr 27 05:41:33 2019 +0000
@@ -10,6 +10,7 @@
 void pid(double,double);
 void out_lo(double);
 void out_li(double);
+void reset();
 
 ////////////定数
 int solution=1000;
@@ -43,8 +44,9 @@
 {
 
     setup();
-    
+    reset();
     while(1) {
+       
        can_send();
        pid(target_lo,target_li);
         wait(0.01);
@@ -61,8 +63,8 @@
     motor_li_b.period_us(100);
 
     hand.mode(PullUp);
-    switch2.mode(PullUp);
-    switch3.mode(PullUp);
+    switch_lo.mode(PullUp);
+    switch_li.mode(PullUp);
     switch4.mode(PullUp);
 
 
@@ -91,6 +93,20 @@
     else led4=0;
 }
 
+void reset()
+{
+    while(switch_lo.read()) {
+        out_lo(0.05);
+    }
+     ec_lo.reset();
+     out_lo(0);
+    while(switch_li.read()) {
+        out_li(0.05);
+    }
+    
+     ec_li.reset();
+     out_li(0);
+}
 
 void out_lo(double duty)
 {
--- a/pin.h	Sat Apr 27 04:28:33 2019 +0000
+++ b/pin.h	Sat Apr 27 05:41:33 2019 +0000
@@ -17,8 +17,8 @@
 HCSR04 sensor(p17, p18);
 
 DigitalIn hand(p20);
-DigitalIn switch2(p25);
-DigitalIn switch3(p26);
+DigitalIn switch_lo(p25);
+DigitalIn switch_li(p26);
 DigitalIn switch4(p27);
 
 DigitalOut led4(LED4);
\ No newline at end of file