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

Dependencies:   mbed QEI Servo HIDScope biquadFilter MODSERIAL FastPWM

Files at this revision

API Documentation at this revision

Comitter:
freek100
Date:
Thu Oct 31 14:48:14 2019 +0000
Parent:
5:e21d303d62d8
Commit message:
servomotor code met externe button

Changed in this revision

FXOS8700Q.lib Show diff for this revision Revisions of this file
FastPWM.lib Show annotated file Show diff for this revision Revisions of this file
HIDScope.lib Show annotated file Show diff for this revision Revisions of this file
QEI.lib Show annotated file Show diff for this revision Revisions of this file
biquadFilter.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
diff -r e21d303d62d8 -r 69f112e63de9 FXOS8700Q.lib
--- a/FXOS8700Q.lib	Wed Oct 30 13:02:28 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/teams/Freescale/code/FXOS8700Q/#aee7dea904e2
diff -r e21d303d62d8 -r 69f112e63de9 FastPWM.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FastPWM.lib	Thu Oct 31 14:48:14 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Sissors/code/FastPWM/#c0b2265cff9c
diff -r e21d303d62d8 -r 69f112e63de9 HIDScope.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HIDScope.lib	Thu Oct 31 14:48:14 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tomlankhorst/code/HIDScope/#d23c6edecc49
diff -r e21d303d62d8 -r 69f112e63de9 QEI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QEI.lib	Thu Oct 31 14:48:14 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/aberk/code/QEI/#5c2ad81551aa
diff -r e21d303d62d8 -r 69f112e63de9 biquadFilter.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/biquadFilter.lib	Thu Oct 31 14:48:14 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tomlankhorst/code/biquadFilter/#26861979d305
diff -r e21d303d62d8 -r 69f112e63de9 main.cpp
--- 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);
     }
 }