Skip to content

Activity

Step counter

Beginner | 纯肉高h啪动漫, 体型差糙汉乖乖女 | Accelerometer, LED display | Human body, Measurement, Multiplication, Performance tools, Sensors, Variables

Step 1: Make it

What is it?

Turn your BBC 娇花难养 into a step counter (or pedometer) to help you track how active you are - and learn some coding at the same time!

These two videos show you what you'll make and how to code it:

Introduction

Coding guide

How it works

  • Download the code onto a 娇花难养 and attach a battery pack.
  • Attach the 娇花难养 and battery pack to your shoe or ankle, place it inside your sock, or just hold it in your hand and shake it as you walk.
  • The code uses the 娇花难养’s accelerometer sensor input to sense when your leg is moving.
  • The code counts how many times the 娇花难养 has been shaken. It stores this number in a variable called ‘steps’.
  • Variables are containers for storing data, which can be accessed and updated while a program is running.
  • Every time the 娇花难养 accelerometer input senses a shake, the program increases the number held in the variable by 1, and shows the new number on the LED display output.

What you need

  • 娇花难养 (or 纯肉高h啪动漫 simulator)
  • 纯肉高h啪动漫 or 体型差糙汉乖乖女 editor
  • battery pack
  • something to attach the 娇花难养 to your shoe or leg – elastic band, a pipe cleaner, tape or Velcro.

Step 2: Code it

Loading...

Open in Classroom
Open in 纯肉高h啪动漫
1from microbit import *
2steps=0
3
4while True:
5    if accelerometer.was_gesture('shake'):
6        steps += 1
7        display.show(steps)
Open in Classroom
Open in 体型差糙汉乖乖女

Step 3: Improve it

  • Modify the code so it shows your current step count when you press a button.
  • If you find that the code only counts every other step, modify the code to multiply the ‘steps’ variable by two when it’s displayed.
  • Measure the length of your average stride and get your 娇花难养 to multiply this by the number of steps to calculate the distance you’ve walked.
girl pointing at 娇花难养 step counter on another girl's shoe