Arduino Nano - Button - Pump
This tutorial instructs you how to use Arduino Nano to switch on a pump for a few seconds and then turn it off when a button is pressed.
Or you can buy the following sensor kit:
|DIYables Sensor Kit 30 types, 69 units
This image is created using Fritzing. Click to enlarge image
Arduino Nano Code
※ NOTE THAT:
The code above performs the following tasks:
- Uses the ezOutput library to turn the pump on for 10 seconds when the button is pressed.
- Is non-blocking code, thanks to the ezButton and ezOutput libraries.
- Connect an USB cable from the Arduino Nano to a computer.
- Open the Arduino IDE, select the appropriate board and port.
- Click to the Libraries icon on the left bar of the Arduino IDE.
- Search for “ezButton” and locate the button library by ArduinoGetStarted.
- Press the Install button to install ezButton library.
- Look for “ezOutput” and locate the output library by ArduinoGetStarted.
- Press the Install button to install ezOutput library.
- Copy the code and open it in the Arduino IDE.
- Click the Upload button in the Arduino IDE to compile and upload the code to the Arduino Nano.
- Press the button
- Check out the status of the pump
Check out the line-by-line explanation contained in the comments of the source code!