Skip to content

Instantly share code, notes, and snippets.

@reefwing
Created March 26, 2023 07:58
Show Gist options
  • Save reefwing/315f2d63e4d7817fd05357bf33408ca1 to your computer and use it in GitHub Desktop.
Save reefwing/315f2d63e4d7817fd05357bf33408ca1 to your computer and use it in GitHub Desktop.
#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