Toshihisa T
/
LSM303DLHTest
LSM303DLH Test Program for get angle.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 00002 #include "mbed.h" 00003 #include "LSM303DLH.h" 00004 00005 Serial debug(USBTX,USBRX); 00006 LSM303DLH compass(p28, p27); 00007 00008 int main() { 00009 float hdg; 00010 float hdgV; 00011 vector acc; 00012 vector mag; 00013 debug.format(8,Serial::None,1); 00014 debug.baud(115200); 00015 debug.printf("LSM303DLH Test\x0d\x0a"); 00016 compass.setOffset(0.00,0.00,0.00); // example calibration 00017 compass.setScale(1.00,1.00,1.00); // example calibration 00018 while(1) { 00019 compass.read(acc,mag); 00020 hdg = compass.heading(); 00021 hdgV = atan2(acc.y,acc.z) * 180/M_PI; 00022 debug.printf("ACC: %6.2f %6.2f %6.2f Heading: %6.2f %6.2f\n",acc.x,acc.y,acc.z,hdgV,hdg); 00023 wait(0.1); 00024 } 00025 } 00026
Generated on Wed Jul 27 2022 20:40:22 by 1.7.2