Black Friday Offer 🔥 Use code BLKFRI at checkout to get 15% OFF on orders above €60!

CodeCell includes a built-in BNO085 3-axis gyroscope that measures angular velocity - how fast CodeCell is rotating around each axis. This lets you detect turning, spinning, or orientation changes.
The gyroscope measures rotation speed in degrees per second (°/s) along three axes:
You can enable and read gyroscope data using two simple functions:
myCodeCell.Init(MOTION_GYRO); // Enable gyroscope sensing
myCodeCell.Motion_GyroRead(x, y, z); // Read angular velocity on all axes
Each reading gives the current rotation speed on the X, Y, and Z axes in °/s.
This example prints live angular velocity readings to the Serial Monitor, showing how fast CodeCell is rotating around each axis.
#include <CodeCell.h>
CodeCell myCodeCell;
float x = 0.0, y = 0.0, z = 0.0;
void setup() {
Serial.begin(115200);
myCodeCell.Init(MOTION_GYRO); // Initialize gyroscope
}
void loop() {
if (myCodeCell.Run(10)) { // Run at 10 Hz
myCodeCell.Motion_GyroRead(x, y, z); // Read gyro data
Serial.print("Gyro X: "); Serial.print(x);
Serial.print(" Y: "); Serial.print(y);
Serial.print(" Z: "); Serial.println(z);
}
}
What You’ll Notice:
0.This example changes CodeCell’s onboard LED color based on rotation direction, red when turning left, green when turning right.
#include <CodeCell.h>
CodeCell myCodeCell;
float x = 0.0, y = 0.0, z = 0.0;
const float ROTATION_THRESHOLD = 3.0; // Rotation speed threshold (°/s)
void setup() {
Serial.begin(115200);
myCodeCell.Init(MOTION_GYRO); // Enable gyroscope
}
void loop() {
if (myCodeCell.Run(10)) { // Run at 10 Hz
myCodeCell.Motion_GyroRead(x, y, z); // Read angular velocity
Serial.print("Gyro Z: ");
Serial.println(z);
if (z > ROTATION_THRESHOLD) { // Rotating right
myCodeCell.LED(0, 255, 0); // Green LED
}
else if (z < -ROTATION_THRESHOLD) { // Rotating left
myCodeCell.LED(255, 0, 0); // Red LED
}
else {
myCodeCell.LED(0, 0, 0); // LED off
}
}
}
How It Works:
Adjust ROTATION_THRESHOLD to control sensitivity:
Join our Community ~ Be the first to know about new products and get exciting deals!
© 2025 Microbots.