servo motor werkt eindelijk!!!! wiehoe!!!

Dependencies:   mbed QEI Servo HIDScope biquadFilter MODSERIAL FastPWM

Revision:
5:e21d303d62d8
Parent:
4:d3e8ec68ff97
Child:
6:69f112e63de9
--- a/main.cpp	Tue Oct 29 20:58:26 2019 +0000
+++ b/main.cpp	Wed Oct 30 13:02:28 2019 +0000
@@ -8,38 +8,34 @@
 MODSERIAL pc(USBTX, USBRX); //connect pc
 Servo myservo(D3); //the servo motor is connected to pin D3 on the BioRobotics shield
 
-//Buttons that will be used to control the servo motor
-InterruptIn button2(SW2); //when this button is pushed, the servo motor rotates 90 degrees counterclockwise
-InterruptIn button3(SW3); //when this button is pushed, the servo motor rotates 90 degrees clockclockwise
+//Button that will be used to control the servo motor
+InterruptIn button2(SW2); //when this button is pushed for the first time, the servo motor rotates to show the card to the user, when the button is pushed for the second time the servo motor rotates the card away from the user
+
 
-void showcard()
-{
+bool showcard=0;
 
+void changeservo()
+{    
+    if (showcard==1){
     myservo.SetPosition(2000);
-    pc.printf("card is being showed to user.\n.\r");
-   
-}
-
-void hidecard()
-{
+    showcard=!showcard;
+    }
+    
+    else {
     myservo.SetPosition(1000);
-    pc.printf("card is being rotated away from user .\n.\r");
-    
+    showcard=!showcard;
+        }    
 }
 
 int main()
 {
     pc.baud(115200);
-    pc.printf("starting main .\r.\n");
     myservo.Enable(1000,20000);
 
-    button2.rise(showcard);
-    button3.rise(hidecard);
+    button2.rise(changeservo);
 
     while(true) {
-        pc.printf("weer begonnen aan mijn main"); //@Jasper hebben we deze nog echt nodgi
-        wait(2);
-
+        
     }
 }