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
- Open MakeCode.
- Create a new project called AccelerationLogger.
- Add blocks to record acceleration every 100 ms.
- Store the maximum acceleration in a variable.
- 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!