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

Dependencies:   mbed QEI Servo HIDScope biquadFilter MODSERIAL FastPWM

Revision:
6:69f112e63de9
Parent:
5:e21d303d62d8
--- a/main.cpp	Wed Oct 30 13:02:28 2019 +0000
+++ b/main.cpp	Thu Oct 31 14:48:14 2019 +0000
@@ -1,22 +1,27 @@
 /* servo motor program - biorbotics group 8 */
 
-#include <Servo.h>
-#include <mbed.h>
-#include <math.h>    /* cos */
-#include <MODSERIAL.h>
+#include "Servo.h"
+#include "mbed.h"
+#include "HIDScope.h"
+#include "QEI.h"
+#include "MODSERIAL.h"
+#include "BiQuad.h"
+#include "FastPWM.h"
 
 MODSERIAL pc(USBTX, USBRX); //connect pc
 Servo myservo(D3); //the servo motor is connected to pin D3 on the BioRobotics shield
-
+DigitalIn extButton1 (D2);
 //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
 
-
 bool showcard=0;
+bool butt1;
+Ticker Servoticker;
 
 void changeservo()
 {    
-    if (showcard==1){
+    butt1= extButton1.read();
+    if (butt1==1){
     myservo.SetPosition(2000);
     showcard=!showcard;
     }
@@ -29,13 +34,19 @@
 
 int main()
 {
+    
     pc.baud(115200);
+    pc.printf("Starting...");
+    
     myservo.Enable(1000,20000);
-
-    button2.rise(changeservo);
-
+    
+    Servoticker.attach(changeservo,0.01);
+    extButton1.mode(PullUp);
+   
+    
     while(true) {
-        
+        pc.printf("Button1: %i \r\n", butt1);
+        wait(0.5);
     }
 }