Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI HIDScope BiQuad4th_order biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 2:3feeeb434275
- Parent:
- 1:b862262a9d14
- Child:
- 3:695daa59763d
--- a/main.cpp	Wed Sep 04 15:30:13 2019 +0000
+++ b/main.cpp	Mon Oct 14 09:48:55 2019 +0000
@@ -1,23 +1,33 @@
 #include "mbed.h"
 //#include "HIDScope.h"
-//#include "QEI.h"
+#include "QEI.h"
 #include "MODSERIAL.h"
 //#include "BiQuad.h"
 //#include "FastPWM.h"
 
-DigitalOut led(LED_RED);
 
 MODSERIAL pc(USBTX, USBRX);
+InterruptIn button(SW3);
+
+Ticker motor;
+volatile int counts;
+void readencoder()
+{
+QEI Encoder(D12,D13,NC,32);
+counts = Encoder.getPulses();
+}
+void print()
+{
+    pc.printf("%i",counts);
+    }
 
 int main()
 {
+    button.mode(PullUp);
     pc.baud(115200);
-    pc.printf("\r\nStarting...\r\n\r\n");
-    
-    while (true) {
-        
-        led = !led;
-        
-        wait_ms(500);
-    }
+    button.rise(print);
+    motor.attach(readencoder, 0.002);
+    while (true)
+    {
 }
+}
\ No newline at end of file