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 Accelerometer

22 June 2021

The Accelerometer

The accelerometer 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 gyroscope.

What Does It Do

The accelerometer detects the acceleration caused by forces acting on the Rover. It’s a great tool for figuring out the Rover’s orientation in the world, think of it as the primary tool for the Rover’s sense of balance.

Important Concepts

Before we get into how an accelerometer works, we need to cover some physics concepts.

Acceleration

Acceleration is the change in velocity of an object. For example, when you go from a walk to a run, you’re accelerating using the forces generated by your muscles. As you slow down, your acceleration decreases. All movement has a rate of acceleration. Whenever the Rover is moved, by gravity, by its motors, or by a hand, that movement has a rate of acceleration.

Forces

When you push the Rover, you’re applying a force to it. When that force is unopposed, the Rover will be in motion. Anything that can apply motion to the Rover and change its position in space is considered a force. Forces fall into two categories: dynamic and static.

  • Dynamic forces can change. When you pick up and move the Rover, your hand moves at an unpredictable, changing rate, so the force applied is dynamic.
  • Static forces do not change. The best example is gravity, the Rover is always affected by gravity, like all objects on Earth.

How Does the Accelerometer Work?

The accelerometer on the Rover is a MEMS accelerometer (microelectromechanical systems). There’s a lot of marvellous engineering inside MEMS, but they’re complicated devices we won’t go into here. To simplify, imagine that inside the accelerometer there is a spring with a weight attached to it. This weight moves around when a force is applied, and as the weight moves, the spring contracts, expands, and tilts. By measuring how the spring contracts, expands, and tilts, the accelerometer can measure acceleration.

Simplified accelerometer model, spring-and-weight

Simplified accelerometer model, spring-and-weight

Walking through an example where the outside force is gravity:

  1. When no force is applied, the spring sits in its default position.
  2. As gravity is applied, the weight is pulled down and the spring compresses under it.
  3. When the Rover is flipped upside down, the accelerometer is too, the weight is still pulled down by gravity, but now the spring is extending.

When the spring compresses or extends, the accelerometer can detect there’s a force being applied to the Rover. Now let’s look at how it communicates where the force is coming from.

The Three Axes of Movement

With the accelerometer, the Rover can detect its acceleration, but it needs a way to communicate it. We need a simple way to understand and communicate the Rover’s direction of motion. That’s what the axes of movement are for.

The X, Y, and Z axes rotating with the Rover

The X, Y, and Z Axes

  • 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.

These axes stay localised to the Rover. As the Rover rotates, the axes rotate with it.

The Three Axes in the Accelerometer

Applying the three axes to our weight-and-spring example: when the Rover sits flat, gravity pulls down on the Rover and the accelerometer detects force against the Z axis.

Rover sitting flat, gravity pulls down against the Z axis

Rover sitting flat, gravity pulls down against the Z axis

When the Rover flips over, the force is still applied downwards, but to the Rover’s underside, the accelerometer detects gravity going with the Z axis.

Rover upside down, gravity now goes with the Z axis

Rover upside down, gravity now goes with the Z axis

Bringing It All Together

The accelerometer is a device built into the Rover. As forces, gravity, your hands, the Rover’s own motors, move the Rover, the accelerometer’s mechanisms shift around. The accelerometer monitors that and calculates which axis is affected by outside forces. We can read this data and program the Rover to respond.

Does Nature Have Accelerometers?

Similar to how the Rover uses the accelerometer to balance, humans have a form of accelerometer in our inner ear.

How the Inner Ear Helps Us Balance

The inner ear has many parts; three of them help with balance, the three semicircular canals: posterior, anterior, and lateral. Inside these canals are tiny hairs and liquid. As we move our head, the liquid shifts back and forth, and the tiny hairs detect the movement and send signals to the brain.

The Rover’s accelerometer is designed to understand movement along three axes. The inner ear does the same, each semicircular canal is responsible for one axis. The lateral canal is for the Z axis, the anterior for the Y axis, and the posterior for the X axis.

Diagram of the ear

Diagram of the ear

Programming the Accelerometer

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 accelerometer values are in the bottom-right table. The first column is the accelerometer values. Move the Rover around and watch how the X, Y, and Z values change.

Opening Sensor View in the Code Editor

Understanding Accelerometer Values

The values in the accelerometer column are g-force values. G-force (g) is a standard unit of measurement for force. 1 g equals the same amount of force applied by Earth’s gravity. When the Rover is in free-fall with no external forces, it will read 0 g in all axes.

Rover sitting upright, Z reads ~1 g

Rover sitting upright, Z reads ~1 g

Rest the Rover upright on a flat surface and you’ll see the X and Y values are roughly 0 g, but the Z value will be roughly 1 g, gravity is pushing down on the Z axis.

If you flip the Rover upside down, X and Y will still be roughly 0 g but Z will read about −1 g, since Earth’s gravity is now going the other way on the Z axis.

Beyond 1 g

Most of the time you’ll only see accelerometer readings between −1 and 1. The accelerometer is configured to track up to ±2 g (the easiest way to see this is to lift your Rover up against gravity). In normal use, the Rover will have to be moving fairly fast to reach high values.

Remember the old Micromelon saying: it’s not the speed that breaks your Rover, it’s the sudden stop.

Using the Accelerometer in Code

Let’s write a simple program to change the Rover’s LEDs depending on the value of the Z axis of the accelerometer.

Building the LED-changes-on-flip program

  1. Add an IF/ELSE block.
  2. Inside the condition, place a Read X Axis From Accelerometer block (in the Sensors category) and change the dropdown to Z Axis. (Python: IMU.readAccel(2).)
  3. Change the second value on the < condition block from 10 to 0, so we’re checking whether the value is positive or negative.
  4. In the IF/ELSE true case, place a Set All LEDs block (in the Lights/Sounds category).
  5. In the false case, place another Set All LEDs block but set it to a different colour.
  6. Place the whole IF/ELSE block in a While True loop.
  7. Press Play.

While running, the Rover’s LEDs change to your selected colours depending on whether it’s right-way-up or upside-down. Flip the Rover over to test it.

Wrapping Up

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

Continue Learning

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

Activity: Flip BotRelated resourceActivity: Flip BotLearn branching, iteration, and how to use the accelerometer.

Activity: Servo GaugeRelated resourceActivity: Servo GaugeUse a micro servo to build a visual gauge that reacts to sensor values, in this activity, a stability gauge driven by the accelerometer.

← Return to Resources