![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Tests for BNO055 IMU and hall sensor interrupts
Revision 0:c462deb7ee50, committed 2016-03-20
- Comitter:
- alex93
- Date:
- Sun Mar 20 03:01:54 2016 +0000
- Commit message:
- Tests for BNO055 IMU and hall sensor interrupts
Changed in this revision
diff -r 000000000000 -r c462deb7ee50 BNO055.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BNO055.lib Sun Mar 20 03:01:54 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/StressedDave/code/BNO055/#1f722ffec323
diff -r 000000000000 -r c462deb7ee50 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Mar 20 03:01:54 2016 +0000 @@ -0,0 +1,48 @@ +/********************************************************************************* +* This code sets the valve motor to a pwm of 0.8. It also sets interrupts for the +* hall sensor input, so on each rising and falling edge, LED1 is flipped, testing +* the ability of the mbed to accurately detect the hall sensor reading. Lastly, +* this code configures the BNO055 and prints the yaw, pitch, and roll to a PC +* terminal. +*********************************************************************************/ + +#include "mbed.h" +#include "BNO055.h" +using namespace std; + +Serial pc(USBTX, USBRX); + +// BNO055 +BNO055 bno055(p28, p27); + +// Hall Sensor +InterruptIn hallVoltage1(p8); +DigitalOut led1(LED1); + +// Motor Driver +PwmOut valve_pwm(p21); + +void flipLed1() { + led1 = !led1; +} + +int main() { + led1 = 0; + hallVoltage1.rise(&flipLed1); + hallVoltage1.fall(&flipLed1); + + valve_pwm = 0.8; + + bno055.reset(); + bno055.setmode(OPERATION_MODE_NDOF); + bno055.write_calibration_data(); + bno055.get_calib(); + while (bno055.calib == 0) { + bno055.get_calib(); + } + + while(1) { + bno055.get_angles(); //query the i2c device + pc.printf("yaw:%6.2f pitch:%6.2f roll:%6.2f\n",bno055.euler.yaw, bno055.euler.pitch, bno055.euler.roll); + } +} \ No newline at end of file
diff -r 000000000000 -r c462deb7ee50 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Mar 20 03:01:54 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa \ No newline at end of file