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.
Hardware Preparation
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables.
Overview of 12V Pump
Pinout
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
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.
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.