Yes. A Raspberry Pi Pico can drive a hobby servo by using an RP2040 PIO state machine to generate the servo’s timed control signal. This guide uses MicroPython on the original Raspberry Pi Pico; PIO is an option for learning programmable I/O or reserving hardware PWM resources, not a requirement for controlling one servo. Because no servo model is specified, check its documentation for supply, signal timing, and safe movement limits before wiring or choosing pulse settings.
Why use PIO to control a servo?
The RP2040 has two PIO blocks, each with four state machines. Raspberry Pi describes PIO state machines as specialized for I/O, with deterministic timing and flexible GPIO mapping. A state machine runs a small program that can produce a repeated signal: a frame period with a pulse whose high duration is set by a value supplied by the main program. Raspberry Pi’s official examples include PIO PWM implementations in both C/C++ and MicroPython.
PIO is useful if the goal is to learn PIO, or if your design benefits from keeping a signal-generation task on a state machine. It is not inherently better for every servo project: hardware PWM is another documented approach, and for just one servo it may be simpler to use. Neither the sources cited here nor the implementation below establishes a universal accuracy or jitter advantage for either method.
What you need to check before connecting the servo
- A Raspberry Pi Pico with the RP2040 and a MicroPython release that supports the documented
rp2.asm_pioandrp2.StateMachinefacilities. - A three-wire hobby servo, with its exact model documentation available. Servo supply requirements, control-signal timing, and allowable travel vary; do not assume one voltage or pulse range is safe for every servo.
- A suitable servo power source and wiring plan confirmed against the servo and board documentation. Do not assume a Pico GPIO pin is intended to power the motor. Where the servo and Pico use separate supplies, follow the manufacturers’ grounding and connection guidance.
- A Pico GPIO pin to carry the control signal, selected to suit your wiring and the PIO program’s pin mapping.
The sources cited here do not identify a particular servo or establish its wiring colors, safe endpoints, or power arrangement. Use the model-specific documentation for those details rather than treating example values as universal.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Generate the servo signal with MicroPython PIO
MicroPython exposes PIO through the rp2 module. The general pattern is to define a PIO program with rp2.asm_pio, create a state machine with rp2.StateMachine, and provide a pulse-width count to the program. The state machine repeats a frame: it holds the output high for the requested count, then low for the remainder of the frame.
Set the frame duration and pulse-width conversion only after checking the servo’s specifications and the PIO program’s clock/divider assumptions. The count supplied to a PIO instruction is not automatically a value in microseconds; the program timing and clock configuration determine how long each instruction takes. A Pico LED PWM example is not a servo calibration: do not reuse its duty-cycle values as safe servo pulse settings.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
The current MicroPython rp2 API documentation describes the module’s PIO facilities, but its “latest” documentation may include features not present in every released MicroPython version. Check the documentation corresponding to the release installed on your Pico before relying on a feature or syntax.
Program structure
- Choose a GPIO pin for the control signal and map that pin in the PIO program.
- Write a PIO loop that sets the pin high, holds it for a count representing the configured pulse width, sets it low, and waits for the remainder of the chosen frame period.
- Instantiate a state machine using the PIO program, the selected pin, and a clock divider consistent with the program’s timing calculations.
- Start the state machine and feed it the pulse-width count calculated from the exact servo’s documented timing.
- Change that count only within the servo manufacturer’s documented operating range. Test movement without commanding unverified endpoints.
This describes the timing logic rather than prescribing code constants: without a specified servo, clock configuration, and documented timing range, fixed pulse counts could imply unsafe or incorrect motion. Raspberry Pi’s Pico-series MicroPython examples include a PIO PWM example to study for the state-machine structure; adapt timing for the servo instead of copying LED duty-cycle values.
Recommended Free Tools
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
MicroPython PIO or hardware PWM for one servo?
| Consideration | PIO | Hardware PWM |
|---|---|---|
| Best fit | Learning PIO or assigning signal generation to a PIO state machine. | A straightforward choice when the project needs one servo signal and does not specifically call for PIO. |
| Resources | Consumes a PIO state machine and uses one of the RP2040’s PIO blocks. | Uses PWM hardware resources; exact setup depends on the board software and pin choice. |
| Software examples | Raspberry Pi provides PIO PWM examples for MicroPython and C/C++. | Pimoroni documents a hardware-PWM Servo class in its RP2040 servo library. |
| Timing changes | Pulse timing is determined by the PIO instructions, state-machine configuration, and supplied count. | Pulse timing is configured through the PWM implementation. Neither cited source benchmarks ease of adjustment, timing accuracy, or jitter. |
For a C/C++ project, Raspberry Pi’s Pico SDK provides hardware APIs, and its pico-examples repository includes a PIO PWM state-machine program. The same key adaptation applies: derive servo pulse timing from the exact servo documentation, not from an LED brightness example.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What if the project needs several servos?
One third-party RP2040 library documents both a hardware-PWM Servo class and a PIO-based ServoCluster. Its README describes the PWM class as supporting up to 16 servos and the PIO cluster as supporting up to 30. These are capacities claimed by that library, not guaranteed limits of every Pico project or a general RP2040 specification.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
The same library describes Pimoroni Servo 2040 as a separate controller board that accepts up to 18 servos. That is an option for a project designed around a larger number of connections, rather than a requirement for one servo on a Pico. Check the library and product documentation for current compatibility, wiring, and power guidance before choosing an approach.
Quick Recap
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Sources and implementation references
- Raspberry Pi Pico SDK and official pico-examples: SDK and C/C++ PIO PWM example.
- Raspberry Pi Pico-series MicroPython examples: includes a PIO PWM example.
- Raspberry Pi C/C++ SDK hardware API documentation: RP2040 hardware peripherals, including PIO and PWM.
- Pimoroni Servo module README: project-specific Servo, ServoCluster, and Servo 2040 descriptions.
- MicroPython rp2 API documentation: PIO programming interface; “latest” may document features absent from released versions.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.

