Theory
📟⚙️ 5. Sensors: Making a step counter
- 🔄 Utilize Microbit accelerometer to detect movement.
- 🚶♂️ Create step-counter project.
- 🏃♂️ Hold Microbit while running for accurate tracking.
- 📊 Define variable ‘steps’ in the project.
- 📈 Increment ‘steps’ variable by 2 for every shake.
- 🛑 Add ‘stop animation’ command under step increment.
- 🔢 Use ‘show number’ command in ‘forever’ loop.
- 🔄 Replace 0 with ‘steps’ variable.
- 🔄 System shows steps count, increments by 2 when Microbit shaken.
- 🔄 Add reset button to reset steps to 0.
- 🅰️ Drag “on button A pressed” from purple input menu, change to A + B.
- 🔄 Require both A and B press for reset, prevents accidental reset.
- 🔄 Set steps to 0 when A and B pressed simultaneously from red variables.
- 🏃♂️ Finish step counter.
- 🔄 Optional: Implement immediate number update on shake to avoid lag.
- ⏳ Lag occurs when system finishes displaying irrelevant number before showing updated count.
- 💥 Eliminate lag by instructing system to immediately switch to next number upon shake.
Download this to your Microbit and hold the Microbit and power pack in one hand. Go for a run and make sure you swing your arms!