source: trunk/Arduino/GSM/libraries/LSM303/examples/Calibrate/Calibrate.ino@ 17994

Last change on this file since 17994 was 17969, checked in by dneise, 10 years ago
adding libraries folder, with LSM303 lib, this takes precedence over any locally installed LSM303 library, e.g. in HOME/arduino-1.0.6/libraries.
File size: 855 bytes
Line 
1#include <Wire.h>
2#include <LSM303.h>
3
4LSM303 compass;
5LSM303::vector<int16_t> running_min = {32767, 32767, 32767}, running_max = {-32768, -32768, -32768};
6
7char report[80];
8
9void setup() {
10 Serial.begin(9600);
11 Wire.begin();
12 compass.init();
13 compass.enableDefault();
14}
15
16void loop() {
17 compass.read();
18
19 running_min.x = min(running_min.x, compass.m.x);
20 running_min.y = min(running_min.y, compass.m.y);
21 running_min.z = min(running_min.z, compass.m.z);
22
23 running_max.x = max(running_max.x, compass.m.x);
24 running_max.y = max(running_max.y, compass.m.y);
25 running_max.z = max(running_max.z, compass.m.z);
26
27 snprintf(report, sizeof(report), "min: {%+6d, %+6d, %+6d} max: {%+6d, %+6d, %+6d}",
28 running_min.x, running_min.y, running_min.z,
29 running_max.x, running_max.y, running_max.z);
30 Serial.println(report);
31
32 delay(100);
33}
Note: See TracBrowser for help on using the repository browser.