QUI test for the BioRobotics Shield and Pololu motor.

Dependencies:   QEI mbed

Revision:
0:f7f02194f5d6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 27 15:35:14 2016 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "QEI.h"
+
+Serial pc(USBTX, USBRX);
+InterruptIn reset_button(D2);
+
+const float ratio = 1.0f/131.25f;
+
+QEI qei(D13, D12, NC, 32);
+
+Ticker printer;
+volatile int seconds_passed = 0;
+
+void onTick() {
+    pc.printf("pulses = %d\r\n", qei.getPulses());
+    pc.printf("revolutions = %d\r\n", qei.getRevolutions());
+    pc.printf("angular velocity = %d degrees/second\r\n", (qei.getPulses() / ++seconds_passed) * (360/32));
+    pc.printf("\n\n");
+}
+
+void reset() {
+    seconds_passed = 0;
+    qei.reset();
+}
+
+int main()
+{
+    pc.baud(115200);
+    qei.reset();
+    printer.attach(onTick, 1);
+    reset_button.fall(reset); //there must be a better/cleaner way to do this.
+    while (true);
+}
\ No newline at end of file