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.
main.cpp@23:0baaa24e04d8, 2015-01-11 (annotated)
- Committer:
- mlimbird
- Date:
- Sun Jan 11 19:54:10 2015 +0000
- Revision:
- 23:0baaa24e04d8
- Parent:
- 22:dbd5c4af83d6
- Child:
- 24:e8fd339db02e
Everything is working with the 9dof header file. Need to calibrate and learn how to read output from each IC next.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mlimbird | 0:80725699690f | 1 | #include "mbed.h" |
m-limbird | 22:dbd5c4af83d6 | 2 | #include "9DOF.h" |
mlimbird | 8:c64f76d4deff | 3 | |
mlimbird | 20:03a3357de805 | 4 | //establish I2C connections |
m-limbird | 22:dbd5c4af83d6 | 5 | I2C i2c( p9, p10 ); |
mlimbird | 8:c64f76d4deff | 6 | |
mlimbird | 20:03a3357de805 | 7 | //establish serial communications with computer via usb |
mlimbird | 8:c64f76d4deff | 8 | Serial pc(USBTX, USBRX); //tx, rx |
mlimbird | 8:c64f76d4deff | 9 | |
mlimbird | 20:03a3357de805 | 10 | //arrays to store data from 9DOF |
mlimbird | 12:509ed716bd58 | 11 | int accelerometer_data[3]; |
mlimbird | 16:1121b66ef27b | 12 | int gyro_data[3]; |
mlimbird | 19:76632ff3e9fc | 13 | int magnetometer_data[3]; |
mlimbird | 8:c64f76d4deff | 14 | |
mlimbird | 0:80725699690f | 15 | int main() { |
mlimbird | 8:c64f76d4deff | 16 | |
mlimbird | 20:03a3357de805 | 17 | //initialize each IC |
mlimbird | 23:0baaa24e04d8 | 18 | init_adxl345(i2c); |
m-limbird | 22:dbd5c4af83d6 | 19 | init_itg3200(i2c); |
mlimbird | 23:0baaa24e04d8 | 20 | init_hmc5883(i2c); |
mlimbird | 9:331dbf3b341d | 21 | |
mlimbird | 12:509ed716bd58 | 22 | while(1) { |
mlimbird | 20:03a3357de805 | 23 | //read from each IC |
mlimbird | 23:0baaa24e04d8 | 24 | read_adxl345(i2c, accelerometer_data); |
mlimbird | 23:0baaa24e04d8 | 25 | pc.printf("ACCEL: %i\t%i\t%i", accelerometer_data[0], accelerometer_data[1], accelerometer_data[2]); |
m-limbird | 22:dbd5c4af83d6 | 26 | read_itg3200(i2c, gyro_data); |
m-limbird | 22:dbd5c4af83d6 | 27 | pc.printf("GYRO: %i\t%i\t%i", gyro_data[0], gyro_data[1], gyro_data[2]); |
mlimbird | 23:0baaa24e04d8 | 28 | read_hmc5883(i2c, magnetometer_data); |
mlimbird | 23:0baaa24e04d8 | 29 | pc.printf("Magnet: %i\t%i\t%i", magnetometer_data[0], magnetometer_data[1], magnetometer_data[2]); |
mlimbird | 0:80725699690f | 30 | } |
mlimbird | 19:76632ff3e9fc | 31 | } |