Raspberry Pi Pico practice problem · Raspberry Pi Pico
Tilt alarm
HardBudget $15MicroPython
The MPU-6050 on GP4/GP5 reports acceleration. Wake it (write 0 to register 0x6B), then read the X and Y acceleration registers (0x3B, four bytes, signed 16-bit).
Light the LED on GP13 when either axis is more than about 5000 counts (roughly 0.3 g), and keep it off when the board is level. The test starts tilted at 45° and levels it after 1.5 s.