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
  • thread (color of your choice)
  • 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 adjust = 0

let ampm = false

let step = 0

step = 0

ampm = false

adjust = 0

minutes = 0

hours = 0

t0 = input.runningTime()

radio.setGroup(77)

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.

//

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

//

Step 4: Getting Your Yoga Pants Ready

Here I modeled the best placement for the micro:bit to be in order to capture the most accurate steps and activities. I ended up choosing the left side of the pants due to the placement of the hidden pocket which was perfect for holding the battery pack.

Step 5: Put Everything Together!

In order to put everything together, I used a pair of leggings that already have a hidden pouch in the waistband area. This allowed me to tuck the battery pack for the micro:bit into a place where it wouldn't fall to the ground and made it easily removable. I then sewed a loop on the leggings to control the wires that was big enough. This also made the micro:bit more removable and also controlled where on the hip it was placed by the user.

Step 6: In the Future...

In the future, there are numerous improvements I would make in order to take this project to the next level. If I had had more time and had taken more time to think about the materials I had needed, I would have used an Arduino or Lilypad. These platforms would have likely allowed for a more versatile and flexible approach to what I actually wanted to do. I think these platforms are more flexible coding wise as well.

Additionally, I would have liked to embed flex sensors or bio sensors into the yoga pants to output even more data for the user. These sensors could take your body temperature and outside temperature and measured it over time. The flex sensors could have probably given a more accurate movement output as well, which could have improved data measurement as well.