Pedometer running on an STM32 Nucleo with an LSM6DS IMU and SSD1306 OLED display.
Raw accelerometer data is noisy, so it goes through a moving average filter first. Then I compute the magnitude of the 3-axis acceleration vector and look for peaks above a threshold.
Added hysteresis to prevent double-counting - a step only registers on the rising edge, and there's a minimum time between valid steps. Without this, running triggered 2-3x the actual step count.
- Step count
- Distance (km or yards, user toggle)
- Daily goal progress
- Buzzer alert when you hit your goal
The joystick navigates menus and a potentiometer sets the step goal.
Everything runs in a main loop polling at fixed intervals. Measured each task's execution time to make sure nothing misses deadlines:
| Task | Rate | Time |
|---|---|---|
| Button scan | 300 Hz | 27 µs |
| Display update | 4 Hz | 637 µs |
| Serial output | 500 Hz | 768 µs |
Total CPU load sits around 40%, plenty of headroom.
Serial output is the heaviest - would use DMA in a v2 to free up cycles.


