PyRasp

← All practice problems

Raspberry Pi Pico practice problem · Raspberry Pi Pico

Servo switch

MediumBudget $11MicroPython

A push button on GP12 (to 3V3) flips a servo on GP16 between its two ends each time it is pressed: 0°, then 180°, then 0°… The servo is powered from VBUS at 50 Hz.

Debounce the contact: after a press, wait about 20 ms before counting it.

More in Raspberry Pi Pico