motorcontrol met ticker

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Files at this revision

API Documentation at this revision

Comitter:
boydmartherus
Date:
Mon Sep 23 13:56:11 2019 +0000
Parent:
4:86872b89b21c
Commit message:
motor + ticeker

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Sep 20 09:32:39 2019 +0000
+++ b/main.cpp	Mon Sep 23 13:56:11 2019 +0000
@@ -1,6 +1,6 @@
 #include "mbed.h"
-#include "MODSERIAL.h";
-#include "FastPWM.h" ;
+#include "MODSERIAL.h"
+#include "FastPWM.h" 
 
 Serial pc(USBTX,USBRX);
 
@@ -13,11 +13,15 @@
 
 FastPWM motor(D5);
 
-int main(){ 
-    printf("Controll with dial\n");    
-        while(true){
-            wait(0.1);
-            printf("motor speed is (%f)\n\r",pot.read()); wait(0.1);
-            motor.write(pot);
-            }
-    }
+Ticker ticker;
+
+void motor_speed()
+{
+    motor.write(pot);
+}
+
+int main()
+{
+    ticker.attach(&motor_speed, 0.001f);
+    while(true){};
+} 
\ No newline at end of file