Pico W water pump on a motor driver
MicroPython on a Pico W: GP14 high and GP15 low keep a small DC water pump running through a two-input motor driver. The whole build, a Raspberry Pi Pico W and 2 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.
Teaching? Assign it to your class in one click.
Beginner About 15 minutes to build and run. Runs in your browser. Free, and no account needed.
The parts retail for about $9.20. On Mokxi they're free.
What you'll learn
- Why motors need a driver chip
- Two input control of a DC motor driver
- Direction set by which input is high
- Setting a pin's starting value with Pin.OUT and value
- Difficulty: Beginner
- Time: About 15 minutes
- Board: Raspberry Pi Pico W
- Parts: 4
How it works
A Pico pin cannot power a pump directly, so an L9110S motor driver sits between them. The driver has two inputs, AIA and AIB, wired to GP14 and GP15. Its outputs OA1 and OA2 feed the mini water pump.
The script holds GP14 high and GP15 low, which tells the driver to run the pump one way. It prints pumping once, then sleeps in a loop. The pump keeps running because the pins stay as they are.
Parts list
4 parts, plus the jumper wires. They retail for about $9.20; on Mokxi they're free.
- 1 × Raspberry Pi Pico W
- 1 × Motor driver, L9110S
- 1 × Mini water pump
- 1 × Power, 3.3 V
Kits that can build it
This starter kit has every part in the circuit. Each kit's page lists what else it can build.
Wiring table
Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.
| Part and pin | Connects to |
|---|---|
| Motor driver, L9110S pin AIA | Raspberry Pi Pico W pin GP14 |
| Motor driver, L9110S pin AIB | Raspberry Pi Pico W pin GP15 |
| Motor driver, L9110S pin GND | Ground |
| Motor driver, L9110S pin VCC | 3.3 V |
| Mini water pump pin V+ | Motor driver, L9110S pin OA1 |
| Mini water pump pin V- | Motor driver, L9110S pin OA2 |
The code
The MicroPython code exactly as the editor opens it. Change a line there and press Run: the board runs it on the official MicroPython firmware, with nothing to compile.
# Pumping: the pump only needs to turn one way, so GP14 stays high and
# GP15 low, and the motor driver keeps it running.
from machine import Pin
import time
Pin(14, Pin.OUT, value=1)
Pin(15, Pin.OUT, value=0)
print("pumping")
while True:
time.sleep(1)
Troubleshooting
The usual mistakes with this circuit, and the fix for each.
- The pump does not run This project
Check that GP14 goes to AIA and GP15 to AIB, and that the driver has VCC and GND. - You want the pump to run the other way This project
Swap the values: set GP14 to 0 and GP15 to 1 in the twoPinlines. - The motor does not turn or stops quickly when both inputs are the same. Motor driver
Each output follows its input. Set one input high and the other low to turn, swap them to reverse. Equal inputs brake the motor rather than coast. Use PWM on one input for speed. - The driver gets hot or the board resets. Motor driver
Power the motors from a separate supply of about 2.5 to 12 V, within the chip's rating, and share ground with the controller. Small motors only: stalled or large motors exceed its roughly 800 mA limit. - A pump wired straight to a microcontroller pin does not run or resets the board. It draws far more than a pin can give. Mini water pump
Switch it with a logic level MOSFET or a transistor with a base resistor, from its own supply of 3 to 6 V. Join the grounds. - The motor spikes damage the driver, or the pump runs dry and burns out. A coil load makes voltage kicks when it stops. Mini water pump
Add a flyback diode across the pump, stripe to the positive side. Keep the pump under water, since a dry run overheats it and wears the seal. - Pins are powered from 5 V, or a 5 V signal goes into a GPIO. The RP2040 pins are 3.3 V only and are not 5 V tolerant. Raspberry Pi Pico W
Power the board from VBUS or VSYS at 5 V, but keep GPIO signals at 3.3 V. Use a level shifter or a divider for 5 V parts. - WiFi code fails to connect, or the on-board LED code does nothing. The LED on the Pico W is not on GP25 like on the plain Pico. Raspberry Pi Pico W
Use the board's LED_BUILTIN name so the library drives it through the WiFi chip. Join a 2.4 GHz network only, with the right SSID and password, and wait for the link before sending.
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.