4180 Lab 2

Dependencies:   mbed wave_player Servo 4DGL-uLCD-SE Motor SDFileSystem LSM9DS1_Library_cal PinDetect X_NUCLEO_53L0A1

Committer:
emilywilson
Date:
Sun Feb 02 21:36:14 2020 +0000
Revision:
0:90df82d4732d
parts 1 and 3;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilywilson 0:90df82d4732d 1 #include "LSM9DS1.h"
emilywilson 0:90df82d4732d 2 #include "part1.h"
emilywilson 0:90df82d4732d 3
emilywilson 0:90df82d4732d 4 DigitalOut myled(LED1);
emilywilson 0:90df82d4732d 5 Serial pc(p9, p10);
emilywilson 0:90df82d4732d 6
emilywilson 0:90df82d4732d 7 int run_part1() {
emilywilson 0:90df82d4732d 8 //LSM9DS1 lol(p9, p10, 0x6B, 0x1E);
emilywilson 0:90df82d4732d 9 LSM9DS1 lol(p9, p10, 0xD6, 0x3C);
emilywilson 0:90df82d4732d 10 lol.begin();
emilywilson 0:90df82d4732d 11 if (!lol.begin()) {
emilywilson 0:90df82d4732d 12 pc.printf("Failed to communicate with LSM9DS1.\n");
emilywilson 0:90df82d4732d 13 }
emilywilson 0:90df82d4732d 14 lol.calibrate();
emilywilson 0:90df82d4732d 15 while(1) {
emilywilson 0:90df82d4732d 16 lol.readTemp();
emilywilson 0:90df82d4732d 17 lol.readMag();
emilywilson 0:90df82d4732d 18 lol.readGyro();
emilywilson 0:90df82d4732d 19
emilywilson 0:90df82d4732d 20 //pc.printf("%d %d %d %d %d %d %d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz), lol.ax, lol.ay, lol.az, lol.mx, lol.my, lol.mz);
emilywilson 0:90df82d4732d 21 //pc.printf("%d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz));
emilywilson 0:90df82d4732d 22 pc.printf("gyro: %d %d %d\n\r", lol.gx, lol.gy, lol.gz);
emilywilson 0:90df82d4732d 23 pc.printf("accel: %d %d %d\n\r", lol.ax, lol.ay, lol.az);
emilywilson 0:90df82d4732d 24 pc.printf("mag: %d %d %d\n\n\r", lol.mx, lol.my, lol.mz);
emilywilson 0:90df82d4732d 25 myled = 1;
emilywilson 0:90df82d4732d 26 wait(2);
emilywilson 0:90df82d4732d 27 myled = 0;
emilywilson 0:90df82d4732d 28 wait(2);
emilywilson 0:90df82d4732d 29 }
emilywilson 0:90df82d4732d 30 }