2017-09-13 02:58:18 -04:00
|
|
|
//
|
|
|
|
// FILE: queryDemo.ino
|
2013-09-30 11:03:06 -04:00
|
|
|
// AUTHOR: Rob Tillaart
|
2017-09-13 02:58:18 -04:00
|
|
|
// VERSION: 0.1.1
|
2013-09-30 11:03:06 -04:00
|
|
|
// PURPOSE: demo app HMC6352 library - query mode for Arduino
|
|
|
|
//
|
2017-09-13 02:58:18 -04:00
|
|
|
// HISTORY:
|
2013-09-30 11:03:06 -04:00
|
|
|
// 0.1.00 - 2011-04-12 initial version
|
2017-09-13 02:58:18 -04:00
|
|
|
// 0.1.1 - 2017-09-13 renamed to .ino
|
|
|
|
//
|
2013-09-30 11:03:06 -04:00
|
|
|
// Released to the public domain
|
|
|
|
//
|
|
|
|
// All disclaimers apply use at own risk
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <Wire.h>
|
|
|
|
#include <hmc6352.h>
|
|
|
|
|
|
|
|
hmc6352 Compass(0x21); // 0x21 <==> 33 <==> 66 >> 1
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(19200);
|
|
|
|
Serial.println("HMC6352: Version ");
|
|
|
|
Serial.println(HMC_LIB_VERSION);
|
|
|
|
Serial.print("current output modus");
|
|
|
|
Serial.println(Compass.getOutputModus());
|
2017-09-13 02:58:18 -04:00
|
|
|
|
2013-09-30 11:09:58 -04:00
|
|
|
int x = Compass.askHeading();
|
2013-09-30 11:03:06 -04:00
|
|
|
//Serial.print("Ask returns: ");
|
2017-09-13 02:58:18 -04:00
|
|
|
//Serial.println(x);
|
2013-09-30 11:03:06 -04:00
|
|
|
}
|
|
|
|
int x;
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
// in query mode it is not needed to ask for a new reading every time
|
|
|
|
// as it will do a new reading directly after the chip is read
|
|
|
|
// and waits until it is asked for.
|
|
|
|
// Try making a fast turn and smile ...
|
|
|
|
x = Compass.readHeading();
|
|
|
|
Serial.print("Degree : ");
|
|
|
|
Serial.println(x);
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
2017-09-13 02:58:18 -04:00
|
|
|
// END OF FILE
|