diff options
| author | Abel Tim <abel@main.home> | 2024-06-20 21:07:25 +0200 |
|---|---|---|
| committer | Abel Tim <abel@main.home> | 2024-06-20 21:07:25 +0200 |
| commit | 0b6f47f099d763bec4b937b9f504b1f7c8471d17 (patch) | |
| tree | 17c5aeef002910044727ebafb5394fe1ece75f6a /IMU_comp | |
| parent | 1655ed81be766b1024a27adf6f00056618a8d028 (diff) | |
| download | robotica-0b6f47f099d763bec4b937b9f504b1f7c8471d17.tar.gz robotica-0b6f47f099d763bec4b937b9f504b1f7c8471d17.zip | |
poster
Diffstat (limited to 'IMU_comp')
| -rw-r--r-- | IMU_comp/IMU_comp.ino | 32 |
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); +} |
