Micromelon Robotics
Platform
Resources
NewsAbout UsDownload
Support
Build Your Kit

Stay in the loop

New activities, teaching guides, and product updates delivered to your inbox.

Micromelon Robotics

Australian-made educational robotics for the next generation of innovators.

contact@micromelon.com.au

Company

  • About Us
  • Privacy Policy
  • Terms and Conditions

Products

  • Micromelon Rover
  • Code Editor
  • Robot Simulator
  • Junior
  • Python Library

Support

  • Resources
  • News
  • Rover Repairs
  • Contact
  • Build Your Kit

© 2026 Micromelon Robotics Pty Ltd. All rights reserved.

ABN 56 623 302 296

← Back to Resources
Sensor Guides

The Gyroscope

24 June 2021

The Gyroscope

The gyroscope is one of the five sensor types on the Micromelon Rover. It’s a component built into the Rover’s PCB (printed circuit board), only about 2.5 mm × 3.0 mm wide and 0.83 mm tall. The same component also includes another sensor: the accelerometer.

What Does It Do

The gyroscope detects how fast the Rover is rotating and in what direction it is rotating. It’s the key tool for understanding the Rover’s rotational movement, think of it as the Rover’s sense of direction.

History of the Gyroscope

A traditional mechanical gyroscope with gimbal rings and a rotor

A traditional mechanical gyroscope with gimbal rings and a rotor

Gyroscopes have existed long before digital devices like the Rover used them, they’ve been used as tools since the 1800s. Traditional gyroscopes are built out of metal loops called gimbal rings that can spin freely, attached to a central piece called the rotor.

The spin axis and rotor are designed to spin at a high speed. As they spin, the attached gimbal rings rotate inside the gyroscope frame. The mechanics are easier to see in motion than to describe, the videos below show a traditional gyroscope when it is and isn’t in motion.

Gyroscope in motion, angular momentum keeps it upright

When the gyroscope’s components are spinning, it remains stable, seemingly against the force of gravity. This is due to a phenomenon called angular momentum: while the spin axis and rotor are spinning fast enough, angular momentum is maintained and the gyroscope keeps its vertical position against gravity. (Footage above sourced from the YouTube channel ScienceOnline.)

How Does the Rover Gyroscope Work?

The gyroscope on the Rover is a MEMS (microelectromechanical system) gyroscope, which mechanically works very differently from a traditional mechanical gyroscope, there’s no spinning rotor or gimbal rings. The fundamental physics is the same, but the engineering is more complicated than we’ll cover here.

To simplify, imagine that inside the Rover there’s a traditional mechanical gyroscope that is constantly in motion (so it always stays straight against gravity). Around the gyroscope is a protractor. When the Rover is flat on the ground, the protractor aligns the gyroscope with 0°.

Simplified Rover gyroscope, gyroscope inside a protractor

Simplified Rover gyroscope, gyroscope inside a protractor

  1. The Rover starts flat. The 0° mark of the protractor is aligned with the gyroscope, there’s no rotation.
  2. As the Rover rotates, the protractor rotates with it. The gyroscope remains stable and straight.
  3. When the Rover stops rotating, the gyroscope now points at a different degree of the protractor.

The Rover determines degrees of rotation based on how the protractor rotates around the gyroscope. The Rover could also rotate backwards/forwards or spin on the spot, to keep things clear we use the three axes of movement.

The Three Axes of Movement

Using the gyroscope, the Rover can detect that it’s rotating, and can also tell you specifically in which direction it’s rotating.

The X, Y, and Z axes on the Rover

The X, Y, and Z axes on the Rover

  • X axis runs from back to front of the Rover.
  • Y axis runs across the Rover middle from left to right.
  • Z axis runs up and down through the Rover.

The Rover can rotate around all three axes. Below are demonstrations of rotation along each axis.

X-axis rotation

Gyroscope Calibration

Although the Rover’s gyroscope is reliable at detecting rotation changes consistently, it won’t always be perfectly accurate. Even when the Rover is completely stationary, the gyroscope may report the slightest amount of rotation. The difference between the gyroscope value and the real rotation is small enough that, in 99% of circumstances, it’ll be inconsequential when programming.

This irregularity is unavoidable for the built-in gyroscope, but you can re-calibrate the Rover’s sensors if you want to make them as accurate as possible.

How to Recalibrate the Gyroscope

Recalibrating the gyroscope from the Code Editor

  1. Open the Code Editor and connect to the Rover you want to calibrate.
  2. In the Code Editor’s program menu, click the Rover button to open the dropdown.
  3. Select Sensor Calibration.
  4. Place the Rover on the most level surface possible (as the dialog instructs).
  5. Press Calibrate.

Your Rover should now be calibrated.

Getting Started With The Micromelon RoverRelated resourceGetting Started With The Micromelon RoverCrash course on basic rover function, how and what to program and starter activities to attempt.

Programming the Gyroscope

Open the Code Editor, connect to a Micromelon Rover, and open Sensor View. Click the ROVER button next to your Rover’s name to open it.

In the Sensor View dialog, the gyroscope values are in the bottom-right table. The second column is the gyroscope values, and the third column is the accumulated gyroscope values. Move the Rover around and watch how the X, Y, and Z values change.

Opening Sensor View in the Code Editor

Gyroscope vs Accumulated Gyroscope

Gyroscope value

The values in the gyroscope column are degrees per second (dps). While the Rover isn’t rotating, the dps value will be roughly 0. If you rotate the Rover on the Z axis at 90 dps, it will take 4 seconds for the Rover to complete a full 360° spin.

Accumulated gyroscope value

The values in the accumulated gyroscope column are accumulated degrees. When you first open Sensor View or run code, the accumulated values are set to 0. As the Rover rotates anticlockwise, the accumulated degrees increase. If you rotate the Rover 360° on the Z axis, the Z value will be 360. Rotate another 180° and the Z value will be 540. The accumulated degrees keep increasing as you rotate. If you rotate in the opposite direction, the degrees decrease.

Which one is better?

Both are useful in different circumstances, depending on the challenge, you may need to use one or both. We’ll cover two coding examples below.

Negative values

We know there are three axes the Rover can rotate around, but should you rotate clockwise or anticlockwise around the axis? The answer is both. Negative values are clockwise rotation; positive values are anticlockwise rotation.

Using the Gyroscope Value in Code

Let’s write a simple program to make the Rover make sounds when it rotates. The faster it rotates, the higher the pitch.

Building the gyroscope-controlled buzzer program

  1. Start with a While True loop, the program needs to repeat to keep getting live data.
  2. Create a variable from the Variables category. Call it gyro.
  3. Set the gyro variable to a Read From Gyroscope block. Change the dropdown to Z Axis (in the Sensors category. Python: IMU.readGyro(2)).
  4. The Rover’s buzzer can’t use negative numbers, so check if the Z-axis gyroscope value is negative. Use an IF block, in the condition, check if gyro is less than 0.
  5. Inside the IF block, when the condition succeeds, update gyro to gyro × −1 using a multiplication block. This ensures gyro is always positive.
  6. Drag out a Play Sound at Hz block from the Lights/Sounds category. Inside it, place gyro × 10 using another multiplication block, multiplying by 10 makes the sound more pronounced.
  7. Press Play.

While running, the Rover makes sound depending on how much it’s rotating around the Z axis. The faster you rotate, the higher the pitch. Give the Rover a spin (carefully).

Using the Accumulated Gyroscope Value in Code

Let’s write a similar program using the accumulated gyroscope value.

Building the accumulated-gyroscope buzzer program

  1. Start with a While True loop.
  2. Create a variable called gyro.
  3. Set gyro to a Read From Accumulated Gyroscope block, with the dropdown set to Z Axis (Python: IMU.readGyroAccum(2)).
  4. Use an IF block to check if gyro is less than 0, and if so multiply it by −1 to keep it positive.
  5. Drag out a Play Sound at Hz block and place gyro inside (no multiplication needed, these numbers are larger than the per-second values).
  6. Press Play.

While running, the Rover makes sound as you rotate it on the Z axis. As you rotate in one direction the sound increases; rotating back the other way winds it down again.

Wrapping Up

Now that you’re familiar with the gyroscope, how it works, and how to program it, try one of the activities below.

Continue Learning

The AccelerometerRelated resourceThe AccelerometerLearn what the accelerometer is, how it works, and how to code it on the Micromelon Rover.

Activity: Balance BotRelated resourceActivity: Balance BotLearn iteration, algorithm design, maths, and how to use the Rover’s accelerometer and motors.

Activity: Maze IIIRelated resourceActivity: Maze IIIMaster maze solving with precise gyroscope turns, wall-following algorithms, and functions to create an efficient maze navigator.

← Return to Resources