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: HMC5883L MMA8451Q PwmIn TinyGPS2 mbed
Fork of tugboat by
Diff: main.cpp
- Revision:
- 0:ee158c8007b4
- Child:
- 2:db76adcdf799
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jul 29 22:58:20 2013 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+#include "GPS.h"
+#include "HMC5883L.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+I2C i2c_bus(PTE0, PTE1);
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+HMC5883L compass(i2c_bus);
+Serial pc(USBTX, USBRX);
+Serial radio(PTC4, PTC3);
+Timer t;
+GPS gps(PTD3,PTD2);
+
+int main(void) {
+
+
+
+ pc.baud(115200);
+ radio.baud(115200);
+ int16_t dCompass[3];
+ float dAcc[3];
+ compass.init();
+
+
+
+
+
+ while (true) {
+
+ if(gps.sample()){
+ pc.printf("lat: %.8f, lon: %.8f\r\n", gps.get_nmea_longitude(), gps.get_nmea_latitude());
+ radio.printf("lat: %.8f, lon: %.8f\r\n", gps.get_nmea_longitude(), gps.get_nmea_latitude());
+ }
+
+ acc.getAccAllAxis(dAcc);
+ pc.printf("xA: %.4f, yA: %.4f, zA: %.4f\r\n", dAcc[0], dAcc[1], dAcc[2]);
+ radio.printf("xA: %.4f, yA: %.4f, zA: %.4f\r\n", dAcc[0], dAcc[1], dAcc[2]);
+ compass.getXYZ(dCompass);
+ pc.printf("xC: %4d, yC: %4d, zC: %4d\r\n", dCompass[0], dCompass[1], dCompass[2]);
+ radio.printf("xC: %4d, yC: %4d, zC: %4d\r\n", dCompass[0], dCompass[1], dCompass[2]);
+ wait(0.5);
+ }
+}
\ No newline at end of file
