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

Committer:
zlmun
Date:
Wed Nov 20 01:11:00 2013 +0000
Revision:
1:36d047c1f0f4
Parent:
0:ed40790a022a
Read the sensor data from Grove-6-Axis Accelerometer and Compass using SeeedArch

Who changed what in which revision?

UserRevisionLine numberNew contents of line
viswesr 0:ed40790a022a 1 #include "mbed.h"
zlmun 1:36d047c1f0f4 2 #include "LSM303DLH.h"
viswesr 0:ed40790a022a 3
zlmun 1:36d047c1f0f4 4 //DigitalOut led(LED1);
zlmun 1:36d047c1f0f4 5 Serial bbb(P1_13,P1_14); //seeedarch pin for the UART communication tx, rx
zlmun 1:36d047c1f0f4 6 LSM303DLH compass(P0_5, P0_4); //seeedarch pin for I2c communication SDA and SCL
zlmun 1:36d047c1f0f4 7
zlmun 1:36d047c1f0f4 8 //PwmOut servo(P1_24); //seeedarch pin for the multiturn servo
viswesr 0:ed40790a022a 9
viswesr 0:ed40790a022a 10 int main()
viswesr 0:ed40790a022a 11 {
zlmun 1:36d047c1f0f4 12 bbb.baud(9600);
zlmun 1:36d047c1f0f4 13
zlmun 1:36d047c1f0f4 14 while(1)
zlmun 1:36d047c1f0f4 15 {
zlmun 1:36d047c1f0f4 16 if(compass.read())
zlmun 1:36d047c1f0f4 17 {
zlmun 1:36d047c1f0f4 18 bbb.printf("ACC:%f %f %f, MAG:%f %f %f\n\r",compass.ax, compass.ay, compass.az, compass.mx, compass.my, compass.mz);
zlmun 1:36d047c1f0f4 19 bbb.printf("Direction = %.0f\n\r", compass.getHeading() * 180 / 3.14159265358979);
zlmun 1:36d047c1f0f4 20 wait(0.5);
zlmun 1:36d047c1f0f4 21 }
viswesr 0:ed40790a022a 22 }
zlmun 1:36d047c1f0f4 23
viswesr 0:ed40790a022a 24 }