Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1993 - 1
/*
2
HMC58X3_basic.pde - Basic reading example for the HMC58X3 library
3
Copyright (C) 2011 Fabio Varesano <fabio at varesano dot net>
4
 
5
 
6
This program is free software: you can redistribute it and/or modify
7
it under the terms of the version 3 GNU General Public License as
8
published by the Free Software Foundation.
9
 
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14
 
15
You should have received a copy of the GNU General Public License
16
along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 
18
*/
19
 
20
// Uncomment the following line if you are using the HMC5843
21
 
22
#include <Wire.h>
23
#include <HMC58X3.h>
24
 
25
HMC58X3 magn;
26
 
27
void setup(void) {
28
  Serial.begin(9600);
29
  Wire.begin();
30
 
31
  // no delay needed as we have already a delay(5) in HMC58X3::init()
32
  magn.init(true); // Dont set mode yet, we'll do that later on.
33
}
34
 
35
void loop() {
36
  int ix,iy,iz;
37
  delay(10);
38
  // Get values, as ints and floats.
39
  magn.getRaw(&ix,&iy,&iz);
40
 
41
  Serial.print(ix);
42
  Serial.print(",");
43
  Serial.print(iy);
44
  Serial.print(",");
45
  Serial.print(iz);
46
  Serial.println(",");
47
}