Skip to content

[PXCT-768] Modulino Movement Gyroscope readings #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions examples/Modulino_Movement/Basic/Basic.ino

This file was deleted.

57 changes: 57 additions & 0 deletions examples/Modulino_Movement/Movement_Basic/Movement_Basic.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Modulino Movement - Simple Serial Output
*
* This example code is in the public domain.
* Copyright (c) 2025 Arduino
* SPDX-License-Identifier: MPL-2.0
*/

#include "Modulino.h"

// Create a ModulinoMovement
ModulinoMovement movement;

float x, y, z;
float roll, pitch, yaw;

void setup() {
Serial.begin(9600);
// Initialize Modulino I2C communication
Modulino.begin();
// Detect and connect to movement sensor module
movement.begin();

}

void loop() {
// Read new movement data from the sensor
movement.update();

// Get acceleration and gyroscope values
x = movement.getX();
y = movement.getY();
z = movement.getZ();
roll = movement.getRoll();
pitch = movement.getPitch();
yaw = movement.getYaw();

// Print acceleration values
Serial.print("A: ");
Serial.print(x, 3);
Serial.print(", ");
Serial.print(y, 3);
Serial.print(", ");
Serial.print(z, 3);

// Print divider between acceleration and gyroscope
Serial.print(" | G: ");

// Print gyroscope values
Serial.print(roll, 1);
Serial.print(", ");
Serial.print(pitch, 1);
Serial.print(", ");
Serial.println(yaw, 1);

delay(200);
}
16 changes: 14 additions & 2 deletions src/Modulino.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,15 @@ class ModulinoMovement : public Module {
}
int update() {
if (initialized) {
return _imu->readAcceleration(x, y, z);
int accel = _imu->readAcceleration(x, y, z);
int gyro = _imu->readGyroscope(roll, pitch, yaw);
return accel && gyro;
}
return 0;
}
int available() {
if (initialized) {
return _imu->accelerationAvailable();
return _imu->accelerationAvailable() && _imu->gyroscopeAvailable();
}
return 0;
}
Expand All @@ -332,9 +334,19 @@ class ModulinoMovement : public Module {
float getZ() {
return z;
}
float getRoll() {
return roll;
}
float getPitch() {
return pitch;
}
float getYaw() {
return yaw;
}
private:
LSM6DSOXClass* _imu = nullptr;
float x,y,z;
float roll,pitch,yaw; //gx, gy, gz
int initialized = 0;
};

Expand Down