![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mini Project 10: Displaying stuff from day 7
Dependencies: DmTouch_UniGraphic UniGraphic mbed
Diff: compass_sensor.cpp
- Revision:
- 12:bd1d030d5c30
- Parent:
- 11:482a9abbc448
diff -r 482a9abbc448 -r bd1d030d5c30 compass_sensor.cpp --- a/compass_sensor.cpp Tue Jan 17 20:34:32 2017 +0000 +++ b/compass_sensor.cpp Tue Jan 17 20:55:08 2017 +0000 @@ -42,12 +42,12 @@ i2c_port.write(addr); //compass is given its address again i2c_port.write(0x03); //told to given 3 bytes i2c_port.stop(); - for (int m = 0; m<2; m++) + for (int m = 0; m<5; m++) //average of 5 { heading = calculation(); //function that calculates the degrees from N sum += heading; //sum of the heading(s) } - heading = sum/2; //the average of the heading(s) collected + heading = sum/5; //the average of the heading(s) collected if (heading > 180){ heading = heading - 360; //if greater than 180, then subtract 360 since it was too large }