Skip to content

활동

만보계

초급 | MakeCode, Python | LED, 가속도 센서 | 곱셈, 변수, 성능 평가 도구, 센서, 인체, 측정

1단계: 만들어 보세요.

프로젝트 소개

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

다음 동영상을 통해 만들고 프로그래밍하는 방법을 살펴보세요.:

소개

프로그래밍 가이드

설명

  • Download the code onto a micro:bit and attach a battery pack.
  • Attach the micro:bit 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 micro:bit’s accelerometer sensor input to sense when your leg is moving.
  • The code counts how many times the micro:bit 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 micro:bit 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.

준비물

  • micro:bit (또는 MakeCode 시뮬레이터)
  • MakeCode 또는 Python 편집기
  • battery pack
  • something to attach the micro:bit to your shoe or leg – elastic band, a pipe cleaner, tape or Velcro.

2단계: 프로그래밍 해보세요.

1from microbit import *
2steps=0
3
4while True:
5    if accelerometer.was_gesture('shake'):
6        steps += 1
7        display.show(steps)

3단계: 더 좋게 만들어 보세요.

  • 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 micro:bit to multiply this by the number of steps to calculate the distance you’ve walked.
어떤 여학생의 신발에 붙여져 있는 micro:bit 를 손으로 가리키고 있는 다른 여학생