Skip to content

Commit db4c28b

Browse files
Added Gyro to Basic
1 parent 7f453d4 commit db4c28b

File tree

2 files changed

+57
-44
lines changed

2 files changed

+57
-44
lines changed

examples/Modulino_Movement/Basic/Basic.ino

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Modulino Movement - Simple Serial Output
3+
*
4+
* This example code is in the public domain.
5+
* Copyright (c) 2025 Arduino
6+
* SPDX-License-Identifier: MPL-2.0
7+
*/
8+
9+
#include "Modulino.h"
10+
11+
// Create a ModulinoMovement
12+
ModulinoMovement movement;
13+
14+
float x, y, z;
15+
float gx, gy, gz;
16+
17+
void setup() {
18+
Serial.begin(9600);
19+
// Initialize Modulino I2C communication
20+
Modulino.begin();
21+
// Detect and connect to movement sensor module
22+
movement.begin();
23+
24+
}
25+
26+
void loop() {
27+
// Read new movement data from the sensor
28+
movement.update();
29+
30+
// Get acceleration and gyroscope values
31+
x = movement.getX();
32+
y = movement.getY();
33+
z = movement.getZ();
34+
gx = movement.getGyroX();
35+
gy = movement.getGyroY();
36+
gz = movement.getGyroZ();
37+
38+
// Print acceleration values
39+
Serial.print("A: ");
40+
Serial.print(x, 3);
41+
Serial.print(", ");
42+
Serial.print(y, 3);
43+
Serial.print(", ");
44+
Serial.print(z, 3);
45+
46+
// Print divider between acceleration and gyroscope
47+
Serial.print(" | G: ");
48+
49+
// Print gyroscope values
50+
Serial.print(gx, 1);
51+
Serial.print(", ");
52+
Serial.print(gy, 1);
53+
Serial.print(", ");
54+
Serial.println(gz, 1);
55+
56+
delay(200);
57+
}

0 commit comments

Comments
 (0)