Корак 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 уређивач
- пакет батерија
- something to attach the micro:bit to your shoe or leg – elastic band, a pipe cleaner, tape or Velcro.
Корак 2: Програмирај
Корак 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.
This content is published under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) licence.