This program reads the data from the LSM303DLM sensor and output that through the UART port.

Dependencies:   LSM303DLH mbed

Fork of Arch_GPIO_Ex1 by Visweswara R

Revision:
1:36d047c1f0f4
Parent:
0:ed40790a022a
--- 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);
+        }
     }
+
 }