Reads IMU and pushbutton trigger, writes to PC over serial.

Dependencies:   LSM9DS0 mbed

Files at this revision

API Documentation at this revision

Comitter:
eshibut3
Date:
Fri Dec 04 05:29:39 2015 +0000
Commit message:
Reads in IMU data and checks for pushbutton trigger, writes to PC over serial.

Changed in this revision

LSM9DS0.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM9DS0.lib	Fri Dec 04 05:29:39 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/aswild/code/LSM9DS0/#5556e6fb99f5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 04 05:29:39 2015 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "LSM9DS0.h"
+
+#define LSM9DS0_XM_ADDR  0x1D // Would be 0x1E if SDO_XM is LOW
+#define LSM9DS0_G_ADDR   0x6B // Would be 0x6A if SDO_G is LOW
+
+LSM9DS0 imu(p9, p10, LSM9DS0_G_ADDR, LSM9DS0_XM_ADDR);
+Serial pc(USBTX, USBRX);
+
+//Extra inputs for 'fake' connections, can ignore
+DigitalIn in0(p21);
+DigitalIn in1(p22);
+DigitalIn in2(p23);
+DigitalIn in3(p17);
+
+//Trigger pushbutton
+DigitalIn trigger(p15);
+
+int main() {
+    //Initialize IMU
+    imu.begin();
+    //Set pushbutton input mode
+    trigger.mode(PullUp);
+    while(1) {
+        imu.readAccel();
+        imu.readGyro();
+        imu.readMag();
+        //IMPORTANT - Unity only recognizes Unix-style line endings in the context of the C# SerialPort.ReadLine() function
+        pc.printf("%f %f %f$%f %f %f$%f %f %f\r\n", imu.ax, imu.ay, imu.az, imu.gx, imu.gy, imu.gz, imu.mx, imu.my, imu.mz);
+        wait(.005);
+        if (!trigger)   //Print constant fire string
+            pc.printf("PEW\r\n");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 04 05:29:39 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file