A pump converts electrical power into fluid movement, typically as a small DC load with two power terminals. It is usually driven through a transistor, relay, or motor driver rather than directly from a microcontroller, because it can draw more current than an Arduino or ESP32 pin can supply.
| Pin | Signal | Description |
|---|---|---|
5V - |
power | 5V DC Negative wire |
5V + |
power | 5V DC Positive wire |
| From | To | Wire |
|---|---|---|
board:5V |
x1:+ |
red |
board:GND |
x1:- |
black |
board:D9 |
x1:1 |
green |
board:GND.1 |
x1:2 |
black |
This example was written and compile-checked for the arduino-uno. Codey Online adapts it to any other supported board for you.
const int pumpPin = 9;
void setup() {
pinMode(pumpPin, OUTPUT);
Serial.begin(9600);
while (!Serial) {
;
}
Serial.println("Pump example starting.");
Serial.println("The pump will turn on for 2 seconds, then off for 2 seconds.");
}
void loop() {
Serial.println("Pump ON");
digitalWrite(pumpPin, HIGH);
delay(2000);
Serial.println("Pump OFF");
digitalWrite(pumpPin, LOW);
delay(2000);
}
Describe what you want to build. Codey Online writes the code, draws the wiring diagram, compiles it and flashes your board straight from the browser.
Start for free