aymen ammari
DIIDevHeads IoT Integration Server
•Created by aymen ammari on 7/23/2024 in #firmware-and-baremetal
Isolating X-Axis Readings from Accelerometer Interference
This is the code I'm working with
#include <Arduino_LSM9DS1.h> // Include the library for the LSM9DS1 IMU
void setup() {
Serial.begin(9600);
while (!Serial);
// Initialize the IMU
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}
Serial.println("IMU initialized!");
}
void loop() {
float x, y, z;
// Check if there is new acceleration data available
if (IMU.accelerationAvailable()) {
// Read the acceleration data
IMU.readAcceleration(x, y, z);
// Print the X-axis acceleration value
Serial.print("X: ");
Serial.println(x);
}
delay(500); // Delay for readability
}
9 replies