Arduino UNO R4 - Control Pump

In this guide, we will learn how to connect an 12V pump to Arduino UNO R4 and how to program an Arduino UNO R4 to control the pump. This tutorial will help you build systems like irrigation for plants, aquariums, or water refilling stations.

Arduino UNO R4 pump

Hardware Preparation

1×Arduino UNO R4 WiFi
1×Arduino UNO R4 Minima (Alternatively)
1×USB Cable Type-C
1×Relay
1×12V Pump
1×Vinyl Tube
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×(Recommended) Screw Terminal Block Shield for Arduino UNO R4
1×(Recommended) Breadboard Shield For Arduino UNO R4
1×(Recommended) Enclosure For Arduino UNO R4

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables.

Overview of 12V Pump

Pinout

Arduino UNO R4 Pump Pinout
image source: diyables.io

A 12V pump typically has two pins.

  • Connect the negative (-) pin (black) to the GND of the DC power supply.
  • Connect the positive (+) pin (red) to the 12V of the DC power supply.

How to Control Pump

If you use a 12V power supply for a 12V pump, it will works. To control the pump using Arduino UNO R4, a relay should be placed between the Arduino UNO R4 and the pump. The Arduino UNO R4 can control the pump through the relay. If you're unfamiliar with relays (their pinout, operation, programming, etc.), you should study them in the Arduino UNO R4 - Relay tutorial.

Wiring Diagram

The wiring diagram between Arduino UNO R4 Pump

This image is created using Fritzing. Click to enlarge image

Arduino UNO R4 Code

The code below repeatedly switches the pump ON for five seconds and then OFF for five regimes.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-controls-pump */ // constants won't change const int RELAY_PIN = 3; // the Arduino pin, which connects to the IN pin of relay // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin D3 as an output. pinMode(RELAY_PIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(RELAY_PIN, HIGH); // turn on pump 5 seconds delay(5000); digitalWrite(RELAY_PIN, LOW); // turn off pump 5 seconds delay(5000); }

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Connect the pump to Arduino UNO R4 via a relay according to the provided diagram.
  • Connect the Arduino Uno R4 board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
  • Copy and paste the provided code into the Arduino IDE.
  • Press the Upload button in the Arduino IDE to send the code to the Arduino UNO R4.
  • Check the state of the pump.

Code Explanation

The explanation is in the comments of the Arduino code above.

Video Tutorial

Challenge Yourself

  • Create an automated watering system with Arduino UNO R4, a soil moisture sensor, and a pump.
  • Build an automatic refill system for water using Arduino UNO R4, a water level sensor, and a pump.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!