2019NHK_teamA / Mbed 2 deprecated PS3_to_servo1

Dependencies:   mbed PS3

Files at this revision

API Documentation at this revision

Comitter:
adaemon
Date:
Mon Jun 17 08:25:54 2019 +0000
Parent:
0:738a25907be7
Commit message:
control servo

Changed in this revision

PS3.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/PS3.lib	Thu Jun 06 23:50:08 2019 +0000
+++ b/PS3.lib	Mon Jun 17 08:25:54 2019 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/sgrsn/code/PS3/#52a4030bed37
+https://os.mbed.com/teams/2019NHK_teamA/code/PS3/#52a4030bed37
--- a/main.cpp	Thu Jun 06 23:50:08 2019 +0000
+++ b/main.cpp	Mon Jun 17 08:25:54 2019 +0000
@@ -11,27 +11,51 @@
 int main(void){
     i2c.frequency(100000);
     int circle;
-    int cross;
+    int old_circle;
+    //int cross;
+    int memo = 0;
     
+    char ninty = 0x01;
+    char zero = 0x02;
+    char nosignal = 0xff;
+    char add = 0x18;
+
     while(1){
         circle = ps3.getButtonState(maru);
-        cross  = ps3.getButtonState(batu);
-        char ninty = 0x01;
-        char zero = 0x02;
-        char nosignal = 0xff;
-        char add = 0x18;
         
-        if(circle == 1){
+        if(circle != old_circle){
+            old_circle = circle;
+            if(circle == 1 && memo == 1){
+                send(add,ninty);
+                memo = 0;
+            }else if(circle == 1 && memo == 0){
+                send(add,zero);
+                memo = 1;
+             }else{
+                send(add,nosignal);
+              }
+        }/*else{
+         send(add,nosignal);
+         }*/
+        
+        
+        //cross  = ps3.getButtonState(batu);
+        
+        /*pc.printf("%4d:%4d\n",circle,memo_servo);
+        
+        if(circle == 1 && memo_servo == 1){
             send(add,ninty);
-            pc.printf("0x01\n");
-            }else if(cross == 1){
+            memo_servo = 0;
+            wait(3);
+            
+            }else if(circle == 1 && memo_servo == 0){
                 send(add,zero);
-                pc.printf("0x02\n");
+                memo_servo = 1;
+                wait(3);
                 }else{
                     send(add,nosignal);
-                    pc.printf("0xff\n");
-                    }
-        }
+                    }*/
+    }
 }
 
 void send(char address,char data){