Micro:bit – Acceleration Logger

Record how fast your rocket accelerates at launch using the built-in accelerometer.

Objective

Log acceleration data and display the maximum ā€œGā€ experienced during flight.

Steps

  1. Open MakeCode.
  2. Create a new project called AccelerationLogger.
  3. Add blocks to record acceleration every 100 ms.
  4. Store the maximum acceleration in a variable.
  5. Display the result when the rocket lands (on shake).

MakeCode JavaScript

let maxA = 0
basic.forever(function () {
  let a = input.acceleration(Dimension.Strength)
  if (a > maxA) {
    maxA = a
  }
  basic.pause(100)
})
input.onGesture(Gesture.Shake, function () {
  basic.showNumber(maxA)
})

Challenge

Convert acceleration to approximate G-forces (divide by 1000) and compare flights!