Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LSM303DLHTest by
Revision 5:05d5e64e76f2, committed 2015-03-18
- Comitter:
- cbelknap
- Date:
- Wed Mar 18 16:48:45 2015 +0000
- Parent:
- 4:3c677edffb13
- Commit message:
- Get magnitude, acceleration and heading
Changed in this revision
LSM303DLH/LSM303DLH.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LSM303DLH/LSM303DLH.cpp Sun May 06 05:30:44 2012 +0000 +++ b/LSM303DLH/LSM303DLH.cpp Wed Mar 18 16:48:45 2015 +0000 @@ -189,7 +189,7 @@ // is pointing. float LSM303DLH::heading() { - return heading((vector){0,-1,0}); + return heading((vector){0,0,1}); } float LSM303DLH::heading(vector from)
--- a/main.cpp Sun May 06 05:30:44 2012 +0000 +++ b/main.cpp Wed Mar 18 16:48:45 2015 +0000 @@ -1,4 +1,3 @@ - #include "mbed.h" #include "LSM303DLH.h" @@ -11,16 +10,18 @@ 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 + debug.baud(9600); + debug.printf("LSM303DLH Test\r\n"); + compass.setOffset(0,0,0); // 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); + hdgV = atan2(acc.y,acc.x) * 180/M_PI; + debug.printf("ACC: %6.2f %6.2f %6.2f\r\n",acc.x,acc.y,acc.z); + debug.printf("MAG: %6.2f %6.2f %6.2f\r\n",mag.x,mag.y,mag.z); + debug.printf("HEAD: %6.2f %6.2f\r\n",hdgV,hdg); + debug.printf("\r\n"); + wait(1); } -} - \ No newline at end of file +} \ No newline at end of file