Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smooth Scroll Wheel

High-resolution rotary scroll wheel using an AS5600 magnetic encoder on a Raspberry Pi Pico RP2040. Emulates a multi-touch trackpad via USB HID for smooth, inertial scrolling on any OS.

Demo

output.mp4

Hardware

  • Raspberry Pi Pico RP2040 (earlephilhower core)
  • AS5600 Magnetic Encoder with diametric magnet
  • I2C Connection: GPIO 4 (SDA), GPIO 5 (SCL)

Wiring

RP2040 Pico    AS5600
----------     ------
GPIO 4     --> SDA
GPIO 5     --> SCL
3.3V       --> VCC
GND        --> GND

Software Setup

  1. Install PlatformIO
  2. Open this project in VS Code with PlatformIO extension
  3. Build and upload to your Pico
  4. Connect USB — device enumerates as a trackpad

How It Works

The AS5600 magnetic sensor tracks rotation at 12-bit (4096 position) precision. Instead of sending mouse wheel events, the firmware reports a virtual two-finger swipe on a touchpad HID device. Rotating the encoder moves a simulated finger up/down, which the OS interprets as smooth scrolling.

  • Hysteresis noise window — deadband absorbs jitter (no drift when idle)
  • Quadratic acceleration — fast spins produce proportionally faster scroll
  • Momentum / inertia — velocity decays gradually (configurable friction) for a trackpad-like coasting feel
  • Boundary reset — when the virtual finger reaches the trackpad edge, it lifts and re-centers, allowing continuous scrolling

Configuration

Key constants in include/AS5600ScrollWheel.h:

Constant Default Description
RESOLUTION 4096 AS5600 ticks per revolution (12-bit)
THRESHOLD 2048 Wrap-around detection midpoint
SCALE 4 Base sensitivity divisor (lower = faster)
NOISE_WINDOW 8 Hysteresis deadband (raw ticks absorbed)
ACCEL_THRESHOLD 4 Movement threshold before acceleration kicks in
ACCEL_DIVISOR 512 Acceleration curve steepness (lower = sharper)
MAX_MOVE 4096 Per-frame displacement safety clamp
MOMENTUM_GAIN 10 Velocity multiplier from raw movement
FRICTION_NUM/DEN 99/100 Velocity retention per frame (99%)
VELOCITY_THRESHOLD 4 Velocity floor — below this, snap to 0
BOUNDARY_LOW 5000 Virtual trackpad Y lower bound (reset point)
BOUNDARY_HIGH 27000 Virtual trackpad Y upper bound (reset point)
TOUCH_CENTER 16384 Y-center of virtual finger

Troubleshooting

  • If AS5600 is not detected, check I2C address (default 0x36)
  • Ensure the magnet is properly positioned over the sensor
  • Verify wiring connections

About

High Resolution (2^15) magnetic scroll wheel based on RP2040

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages