Created
March 26, 2023 07:58
-
-
Save reefwing/315f2d63e4d7817fd05357bf33408ca1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_Sensor.h> | |
#include <Adafruit_LSM9DS1.h> | |
Adafruit_LSM9DS1 lsm; | |
void setup() { | |
Serial.begin(9600); | |
if (!lsm.begin()) { | |
Serial.println("Failed to initialize LSM9DS1!"); | |
while (1); | |
} | |
} | |
void loop() { | |
lsm.read(); | |
float roll = lsm.gyroData().x; | |
float pitch = lsm.gyroData().y; | |
float yaw = lsm.gyroData().z; | |
Serial.print("Roll: "); | |
Serial.print(roll); | |
Serial.print("\tPitch: "); | |
Serial.print(pitch); | |
Serial.print("\tYaw: "); | |
Serial.println(yaw); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment