Page 155 - KEC Khaitan C5 Flipbook
P. 155
let stepGoal = 1000
basic.forever(function () {
if (stepCount >= stepGoal) {
basic.showString("Goal Reached!")
}
})
CALORIE ESTIMATION BASED ON STEPS
The steps to create a calorie estimator are as follows:
1. Assume an average calorie burn rate per step (e.g., 0.04 kcal per step).
2. Multiply stepCount by this factor to estimate calories burned.
3. Display the estimated calorie burn on the Micro:bit.
let stepCount = 0
basic.forever(function () {
let calories = stepCount * 0.04
basic.showString("Calories: ")
basic.showNumber(calories)
})
REVISIT
▶ The Micro:bit is equipped with an accelerometer sensor that helps detect movement,
making it an ideal tool for building a simple pedometer.
▶ Gesture Events block detect movement such as shaking, tilting, or free fall.
▶ To improve accuracy, instead of using the shake gesture, you can use the acceleration
function with threshold values to detect steps more reliably.
▶ A variable is a storage location for data that can change over time.
▶ By setting custom parameters, we ensure that the step counter reacts only to valid walking
movements.
Maker with Micro:bit 153

