This program reads the data from the LSM303DLM sensor and output that through the UART port.
Fork of Arch_GPIO_Ex1 by
Revision 1:36d047c1f0f4, committed 2013-11-20
- Comitter:
- zlmun
- Date:
- Wed Nov 20 01:11:00 2013 +0000
- Parent:
- 0:ed40790a022a
- Commit message:
- Read the sensor data from Grove-6-Axis Accelerometer and Compass using SeeedArch
Changed in this revision
| LSM303DLH.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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LSM303DLH.lib Wed Nov 20 01:11:00 2013 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/yamaguch/code/LSM303DLH/#9b2a0b783bfc
--- a/main.cpp Thu Sep 05 02:19:37 2013 +0000
+++ b/main.cpp Wed Nov 20 01:11:00 2013 +0000
@@ -1,15 +1,24 @@
#include "mbed.h"
+#include "LSM303DLH.h"
-/* Configure a GPIO pin as output for controlling a LED. 'led' is user assigned name and
- 'LED1' is a internal name given to a port pin P1_8 in this Arch platform. */
-DigitalOut led(LED1);
+//DigitalOut led(LED1);
+Serial bbb(P1_13,P1_14); //seeedarch pin for the UART communication tx, rx
+LSM303DLH compass(P0_5, P0_4); //seeedarch pin for I2c communication SDA and SCL
+
+//PwmOut servo(P1_24); //seeedarch pin for the multiturn servo
int main()
{
- while(1) {
- led = 1; // Switch ON the LED.
- wait(0.5); // Wait for 0.5 Seconds.
- led = 0; // Switch OFF the LED.
- wait(0.5); // Wait for 0.5 Seconds.
+ bbb.baud(9600);
+
+ while(1)
+ {
+ if(compass.read())
+ {
+ bbb.printf("ACC:%f %f %f, MAG:%f %f %f\n\r",compass.ax, compass.ay, compass.az, compass.mx, compass.my, compass.mz);
+ bbb.printf("Direction = %.0f\n\r", compass.getHeading() * 180 / 3.14159265358979);
+ wait(0.5);
+ }
}
+
}
