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.
Q3.cpp
- Committer:
- louisverzellesi
- Date:
- 2018-11-18
- Revision:
- 0:baf388d9e3b7
File content as of revision 0:baf388d9e3b7:
// LSM9DS91 Demo
#include "mbed.h"
#include "LSM9DS1.h"
// refresh time. set to 500 for part 2 and 50 for part 4
#define REFRESH_TIME_MS 1000
// Verify that the pin assignments below match your breadboard
LSM9DS1 imu(p9, p10);
Serial pc(USBTX, USBRX);
LocalFileSystem local("local");
DigitalOut myled(LED1);
int i;
float j;
//Init Serial port and LSM9DS1 chip
void setup()
{
// Use the begin() function to initialize the LSM9DS0 library.
// You can either call it with no parameters (the easy way):
uint16_t status = imu.begin();
//Make sure communication is working
pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status);
pc.printf("Should be 0x683D\r\n");
}
int main()
{
FILE *fp = fopen("/local/mesures.csv", "w");
setup(); //Setup sensor and Serial
pc.printf("------ LSM9DS1 Demo -----------\r\n");
while (true)
{
for (i=0;i<=99;i=i++){
imu.readAccel();
imu.readGyro();
imu.readMag();
fprintf(fp,"%d;%2f; %2f; %2f;%2f; %2f; %2f;%2f; %2f; %2f\r\n", i,imu.ax, imu.ay, imu.az,imu.gx, imu.gy, imu.gz,imu.mx, imu.my, imu.mz);
myled = 1;
wait_ms(0.1);
}
myled = 0;
fclose(fp);
}
}