![](/media/cache/group/flyingpig-cover.png.50x50_q85.jpg)
Sample code for LSM9DS1 IMU
main.cpp@0:e068f5847209, 2019-11-07 (annotated)
- Committer:
- CodyMarquardt
- Date:
- Thu Nov 07 23:22:46 2019 +0000
- Revision:
- 0:e068f5847209
This is a sample code for the LSM9DS1 IMU
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CodyMarquardt | 0:e068f5847209 | 1 | #include "mbed.h" |
CodyMarquardt | 0:e068f5847209 | 2 | #include "LSM9DS1.h" |
CodyMarquardt | 0:e068f5847209 | 3 | |
CodyMarquardt | 0:e068f5847209 | 4 | |
CodyMarquardt | 0:e068f5847209 | 5 | Serial pc(USBTX,USBRX); |
CodyMarquardt | 0:e068f5847209 | 6 | LSM9DS1 imu(p28,p27); |
CodyMarquardt | 0:e068f5847209 | 7 | |
CodyMarquardt | 0:e068f5847209 | 8 | int main(){ |
CodyMarquardt | 0:e068f5847209 | 9 | imu.begin(); |
CodyMarquardt | 0:e068f5847209 | 10 | while(1){ |
CodyMarquardt | 0:e068f5847209 | 11 | imu.readAccel(); |
CodyMarquardt | 0:e068f5847209 | 12 | imu.readGyro(); |
CodyMarquardt | 0:e068f5847209 | 13 | imu.readMag(); |
CodyMarquardt | 0:e068f5847209 | 14 | pc.printf("Accelerometer: x = %8f, y = %8f, z = %8f\n\r",imu.ax,imu.ay, imu.az); |
CodyMarquardt | 0:e068f5847209 | 15 | pc.printf("Gyro: x = %f, y = %f, z = %f\n\r",imu.gx,imu.gy, imu.gz); |
CodyMarquardt | 0:e068f5847209 | 16 | pc.printf("Magnetometer: x = %f, y = %f, z = %f\n\n\n\r",imu.mx,imu.my, imu.mz); |
CodyMarquardt | 0:e068f5847209 | 17 | wait(1); |
CodyMarquardt | 0:e068f5847209 | 18 | } |
CodyMarquardt | 0:e068f5847209 | 19 | } |