source: trunk/Arduino/GSM/Calibrate500/Calibrate500.ino@ 18350

Last change on this file since 18350 was 17968, checked in by ghughes, 10 years ago
Arduino Software Stuff
File size: 1.1 KB
Line 
1#include <Wire.h>
2#include <LSM303.h>
3
4LSM303 compass;
5LSM303::vector running_min = {2047, 2047, 2047}, running_max = {-2048, -2048, -2048};
6
7void setup() {
8 Serial.begin(9600);
9 Serial.println("Starting ...");
10 Wire.begin();
11 Serial.println("Ini Wire");
12 compass.init();
13 Serial.println("Ini compass ...");
14 compass.enableDefault();
15}
16
17void loop() {
18 compass.read();
19
20 running_min.x = min(running_min.x, compass.m.x);
21 running_min.y = min(running_min.y, compass.m.y);
22 running_min.z = min(running_min.z, compass.m.z);
23
24 running_max.x = max(running_max.x, compass.m.x);
25 running_max.y = max(running_max.y, compass.m.y);
26 running_max.z = max(running_max.z, compass.m.z);
27
28 Serial.print("M min ");
29 Serial.print("X: ");
30 Serial.print((int)running_min.x);
31 Serial.print(" Y: ");
32 Serial.print((int)running_min.y);
33 Serial.print(" Z: ");
34 Serial.print((int)running_min.z);
35
36 Serial.print(" M max ");
37 Serial.print("X: ");
38 Serial.print((int)running_max.x);
39 Serial.print(" Y: ");
40 Serial.print((int)running_max.y);
41 Serial.print(" Z: ");
42 Serial.println((int)running_max.z);
43
44 delay(100);
45}
Note: See TracBrowser for help on using the repository browser.