mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
51 lines
870 B
C++
51 lines
870 B
C++
//
|
|
// FILE: A1301_demo
|
|
// AUTHOR: Rob Tillaart
|
|
// PURPOSE: demo A1301 A1302 magnetometer.
|
|
|
|
|
|
#include "Arduino.h"
|
|
#include "A1301.h"
|
|
|
|
A1301 mm(A0);
|
|
|
|
uint32_t lastTime = 0;
|
|
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
Serial.println();
|
|
Serial.println(__FILE__);
|
|
Serial.print("A1301_LIB_VERSION: ");
|
|
Serial.println(A1301_LIB_VERSION);
|
|
|
|
mm.begin(5000, 1023);
|
|
}
|
|
|
|
|
|
void loop()
|
|
{
|
|
if (millis() - lastTime >= 1000)
|
|
{
|
|
lastTime = millis();
|
|
Serial.print(mm.raw());
|
|
Serial.print("\t");
|
|
Serial.print(mm.read());
|
|
Serial.print("\t");
|
|
Serial.print(mm.isNorth());
|
|
Serial.print("\t");
|
|
Serial.print(mm.isSouth());
|
|
Serial.print("\t");
|
|
Serial.print(mm.isSaturated());
|
|
Serial.print("\t");
|
|
Serial.print(mm.prevGauss());
|
|
Serial.print("\t");
|
|
Serial.print(mm.lastGauss());
|
|
Serial.print("\n");
|
|
}
|
|
}
|
|
|
|
|
|
// -- END OF FILE --
|