Arduino Nano - Pump
This tutorial instructs you how to use Arduino Nano to control a pump. From this tutorial, you can create an irrigation system, an aquarium, a water refilling system .. and more.
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
The Pump Pinout
The 12V Pump typically has two pins:
- The negative (-) pin (black) should be connected to the GND of the DC power supply
- The positive (+) pin (red) should be connected to the 12V of the DC power supply
How to Control Pump using Arduino Nano
If a 12V pump is powered by a 12V power supply, it will work. In order to control the pump, a relay must be used between the Arduino Nano and the pump. The Arduino Nano can then control the pump through the relay.
If you are unfamiliar with relays (pinout, how they work, how to program them, etc.), please refer to the Arduino Nano - Relay tutorial for more information.
Wiring Diagram
This image is created using Fritzing. Click to enlarge image
Arduino Nano Code
The code below runs an infinite loop that turns the pump ON for five seconds and OFF for five seconds.
Detailed Instructions
- Attach the Arduino Nano to your computer using a USB cable.
- Launch the Arduino IDE and select the appropriate board and port.
- Copy the code above and open it in the Arduino IDE.
- Click the Upload button in the Arduino IDE to send the code to the Arduino Nano.
- Check out the pump's state change.
Code Explanation
Check out the line-by-line explanation contained in the comments of the source code!
Check out this tutorial on Arduino Nano - if a button is pressed, turn the pump on after 10 seconds