Debug buttons and sensor inputs
Make input behaviour visible.
Build or compare
Build a separate test that displays which event fired or shows the raw sensor reading.
Test the result
Reintroduce one block at a time and record the first change that reproduces the issue.