This program reads the data from the LSM303DLM sensor and output that through the UART port.
Fork of Arch_GPIO_Ex1 by
main.cpp
00001 #include "mbed.h" 00002 #include "LSM303DLH.h" 00003 00004 //DigitalOut led(LED1); 00005 Serial bbb(P1_13,P1_14); //seeedarch pin for the UART communication tx, rx 00006 LSM303DLH compass(P0_5, P0_4); //seeedarch pin for I2c communication SDA and SCL 00007 00008 //PwmOut servo(P1_24); //seeedarch pin for the multiturn servo 00009 00010 int main() 00011 { 00012 bbb.baud(9600); 00013 00014 while(1) 00015 { 00016 if(compass.read()) 00017 { 00018 bbb.printf("ACC:%f %f %f, MAG:%f %f %f\n\r",compass.ax, compass.ay, compass.az, compass.mx, compass.my, compass.mz); 00019 bbb.printf("Direction = %.0f\n\r", compass.getHeading() * 180 / 3.14159265358979); 00020 wait(0.5); 00021 } 00022 } 00023 00024 }
Generated on Wed Jul 13 2022 17:32:42 by 1.7.2