Arduino - Button - Pump
We are going to learn how to use Arduino to turn on a pump several seconds and then turn off when a button is pressed.
|1||×||Arduino UNO or Genuino UNO|
|1||×||USB 2.0 cable type A/B|
|1||×||12V Power Adapter|
|1||×||DC Power Jack|
|1||×||(Optional) 9V Power Adapter for Arduino|
|1||×||(Optional) Screw Terminal Block Shield for Arduino Uno|
Or you can buy the following sensor kit:
|1||×||DIYables Sensor Kit 30 types, 69 units|
This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
The above code does:
- If the button is pressed, turned pump on 10 seconds and then turn it off (supported by ezOutput library)
- All code is non-blocking code (supported by ezButton and ezOutput libraries)
- Connect Arduino to PC via USB cable
- Open Arduino IDE, select the right board and port
- On Arduino IDE, Go to Tools Manage Libraries
- Search “ezButton”, then find the button library by ArduinoGetStarted
- Click Install button to install ezButton library.
- Search “ezOutput”, then find the output library by ArduinoGetStarted
- Click Install button to install ezOutput library.
- Copy the above code and open with Arduino IDE
- Click Upload button on Arduino IDE to upload code to Arduino
- Press the button
- See the pump's state
Read the line-by-line explanation in comment lines of source code!
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.