summaryrefslogtreecommitdiff
path: root/IMU_comp
diff options
context:
space:
mode:
authorAbel Tim <abel@main.home>2024-06-20 21:07:25 +0200
committerAbel Tim <abel@main.home>2024-06-20 21:07:25 +0200
commit0b6f47f099d763bec4b937b9f504b1f7c8471d17 (patch)
tree17c5aeef002910044727ebafb5394fe1ece75f6a /IMU_comp
parent1655ed81be766b1024a27adf6f00056618a8d028 (diff)
downloadrobotica-0b6f47f099d763bec4b937b9f504b1f7c8471d17.tar.gz
robotica-0b6f47f099d763bec4b937b9f504b1f7c8471d17.zip
poster
Diffstat (limited to 'IMU_comp')
-rw-r--r--IMU_comp/IMU_comp.ino32
1 files changed, 32 insertions, 0 deletions
diff --git a/IMU_comp/IMU_comp.ino b/IMU_comp/IMU_comp.ino
new file mode 100644
index 0000000..40d99b6
--- /dev/null
+++ b/IMU_comp/IMU_comp.ino
@@ -0,0 +1,32 @@
+//https://www.pololu.com/product/2862
+#include <Wire.h>
+#include <LIS3MDL.h>
+
+LIS3MDL mag;
+
+char report[80];
+
+void setup()
+{
+ Serial.begin(9600);
+ Wire.begin();
+
+ if (!mag.init())
+ {
+ Serial.println("Failed to detect and initialize magnetometer!");
+ while (1);
+ }
+
+ mag.enableDefault();
+}
+
+void loop()
+{
+ mag.read();
+
+ snprintf(report, sizeof(report), "M: %6d %6d %6d",
+ mag.m.x, mag.m.y, mag.m.z);
+ Serial.println(report);
+
+ delay(100);
+}