![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
LSM303DLH Test Program for get angle.
Dependencies: L3GD20 LSM303DLHC SDFileSystemLatch mbed nrf51_rtc
Fork of LSM303DLHTest by
Diff: main.cpp
- Revision:
- 4:3c677edffb13
- Parent:
- 3:f3796683b4c9
- Child:
- 5:b1a689c55f59
diff -r f3796683b4c9 -r 3c677edffb13 main.cpp --- a/main.cpp Sun May 06 05:14:30 2012 +0000 +++ b/main.cpp Sun May 06 05:30:44 2012 +0000 @@ -1,26 +1,26 @@ #include "mbed.h" - #include "LSM303DLH.h" +#include "LSM303DLH.h" - Serial debug(USBTX,USBRX); - LSM303DLH compass(p28, p27); +Serial debug(USBTX,USBRX); +LSM303DLH compass(p28, p27); - int main() { - float hdg; - float hdgV; - vector acc; - vector mag; - debug.format(8,Serial::None,1); - debug.baud(115200); - debug.printf("LSM303DLH Test\x0d\x0a"); - compass.setOffset(0.00,0.00,0.00); // example calibration - compass.setScale(1.00,1.00,1.00); // example calibration - while(1) { - compass.read(acc,mag); - hdg = compass.heading(); - hdgV = atan2(acc.y,acc.z) * 180/M_PI; - debug.printf("ACC: %6.2f %6.2f %6.2f Heading: %6.2f %6.2f\n",acc.x,acc.y,acc.z,hdgV,hdg); - wait(0.1); - } - } +int main() { + float hdg; + float hdgV; + vector acc; + vector mag; + debug.format(8,Serial::None,1); + debug.baud(115200); + debug.printf("LSM303DLH Test\x0d\x0a"); + compass.setOffset(0.00,0.00,0.00); // example calibration + compass.setScale(1.00,1.00,1.00); // example calibration + while(1) { + compass.read(acc,mag); + hdg = compass.heading(); + hdgV = atan2(acc.y,acc.z) * 180/M_PI; + debug.printf("ACC: %6.2f %6.2f %6.2f Heading: %6.2f %6.2f\n",acc.x,acc.y,acc.z,hdgV,hdg); + wait(0.1); + } +} \ No newline at end of file