dad

Dependencies:   mbed-os FXAS21000 LED_Bar FXOS8700Q

Committer:
priyank12p
Date:
Fri Jan 15 22:11:19 2021 +0000
Revision:
0:838685d68d89
Child:
1:7a49fd0692fd
First Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
priyank12p 0:838685d68d89 1 #include "mbed.h"
priyank12p 0:838685d68d89 2 #include "FXOS8700Q.h"
priyank12p 0:838685d68d89 3 #include "FXAS21000.h"
priyank12p 0:838685d68d89 4 I2C i2c(PTE25, PTE24);
priyank12p 0:838685d68d89 5 Serial pc(USBTX,USBRX);
priyank12p 0:838685d68d89 6 FXOS8700QAccelerometer acc(i2c, FXOS8700CQ_SLAVE_ADDR1); // Configured for the FRDM-K64F with onboard sensors
priyank12p 0:838685d68d89 7 FXOS8700QMagnetometer mag(i2c, FXOS8700CQ_SLAVE_ADDR1);
priyank12p 0:838685d68d89 8 FXAS21000 gyro(D14,D15);
priyank12p 0:838685d68d89 9 int main(void)
priyank12p 0:838685d68d89 10 {
priyank12p 0:838685d68d89 11 float gyro_data[3];
priyank12p 0:838685d68d89 12 motion_data_units_t acc_data, mag_data;
priyank12p 0:838685d68d89 13 motion_data_counts_t acc_raw, mag_raw;
priyank12p 0:838685d68d89 14 float faX, faY, faZ, fmX, fmY, fmZ, tmp_float;
priyank12p 0:838685d68d89 15 int16_t raX, raY, raZ, rmX, rmY, rmZ, tmp_int;
priyank12p 0:838685d68d89 16 acc.enable();
priyank12p 0:838685d68d89 17 mag.enable();
priyank12p 0:838685d68d89 18 while (true) {
priyank12p 0:838685d68d89 19 // counts based results
priyank12p 0:838685d68d89 20 acc.getAxis(acc_raw);
priyank12p 0:838685d68d89 21 mag.getAxis(mag_raw);
priyank12p 0:838685d68d89 22 acc.getX(raX);
priyank12p 0:838685d68d89 23 acc.getY(raY);
priyank12p 0:838685d68d89 24 acc.getZ(raZ);
priyank12p 0:838685d68d89 25 mag.getX(rmX);
priyank12p 0:838685d68d89 26 mag.getY(rmY);
priyank12p 0:838685d68d89 27 mag.getZ(rmZ);
priyank12p 0:838685d68d89 28 // unit based results
priyank12p 0:838685d68d89 29 acc.getAxis(acc_data);
priyank12p 0:838685d68d89 30 mag.getAxis(mag_data);
priyank12p 0:838685d68d89 31 acc.getX(faX);
priyank12p 0:838685d68d89 32 acc.getY(faY);
priyank12p 0:838685d68d89 33 acc.getZ(faZ);
priyank12p 0:838685d68d89 34 mag.getX(fmX);
priyank12p 0:838685d68d89 35 mag.getY(fmY);
priyank12p 0:838685d68d89 36 mag.getZ(fmZ);
priyank12p 0:838685d68d89 37 pc.printf("FXOSQ8700Q ACC: X=%1.4fY=%1.4fZ=%1.4f", acc.getX(faX),acc.getY(faY),acc.getZ(faZ));
priyank12p 0:838685d68d89 38 pc.printf(" MAG: X=%4.1fY=%4.1fZ=%4.1f\r\n", mag.getX(fmX),mag.getY(fmY), mag.getZ(fmZ));
priyank12p 0:838685d68d89 39 gyro.ReadXYZ(gyro_data);
priyank12p 0:838685d68d89 40 pc.printf("FXAS21000 Gyro: X=%6.2fY=%6.2fZ=%6.2f\r\n", gyro_data[0],gyro_data[1], gyro_data[2]);
priyank12p 0:838685d68d89 41 wait(1.0f);
priyank12p 0:838685d68d89 42 }
priyank12p 0:838685d68d89 43 }