## Introduction: Activity Tracker + Yoga Pants

This project was designed to monitor your activity and remind those who have been sitting or inactive for a long period of time to move around and take a break.

## Step 1: Supplies

• 2 BBC Microbits
• 2 battery packs
• 1 pair of yoga pants
• sewing kit

## Step 2: Programming Your Activity Tracker (1st Micro:bit)

I have listed the code below that I used to measure how many steps the individual was achieving.

Additionally, there is code to program a clock to keep track of the time and the elapsed time between steps. This elapsed time triggers the second micro:bit to play a sound and show an emoji when too much time has passed between steps.

//

input.onButtonPressed(Button.A, function () {
if (hours < 23) { hours += 1 } else { hours = 0 } })

input.onButtonPressed(Button.B, function () { if (minutes < 59) { minutes += 1 } else { minutes = 0 } })

input.onButtonPressed(Button.AB, function () { adjust = hours if (ampm) { if (hours > 12) { adjust = hours - 12 } else { if (hours == 0) { adjust = 12 } } } time = "" + adjust time = "" + time + ":" if (minutes < 10) { time = "" + time + "0" } time = "" + time + minutes basic.showString(time) })

input.onGesture(Gesture.Shake, function () { step += 1 prevStep = step elapsed = input.runningTime() - t0 actual_elapsed = Math.idiv(elapsed, 1000) radio.sendNumber(actual_elapsed) })

let elapsed = 0

let prevStep = 0

let actual_elapsed = 0

let time = "" let t0 = 0

let hours = 0

let minutes = 0

let ampm = false

let step = 0

step = 0

ampm = false

minutes = 0

hours = 0

t0 = input.runningTime()

basic.forever(function () { basic.showNumber(step) })

//

## Step 3: Programming Your Activity Notifier (2nd Micro:bit)

This code here is needed to program the second micro:bit to show us an emoji and play a sound when too much time has passed between steps.

//

if (actual_elapsed >= 10) { basic.showIcon(IconNames.Asleep) music.beginMelody(music.builtInMelody(Melodies.Prelude), MelodyOptions.Once) } basic.showNumber(actual_elapsed) })

//