• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Arduino 3V DC Mini Pump with Push Button Control and LED Indicators (For Kids)

By Abhishek Ghosh May 18, 2024 10:56 pm Updated on May 18, 2024

Arduino 3V DC Mini Pump with Push Button Control and LED Indicators (For Kids)

Advertisement

Here’s an Arduino sketch to control a 3V DC pump using a push button to start and stop the pump. Additionally, it includes two indicators (green and red LEDs) to signify the status of the pump (running or stopped). This project is intended for the kids, however parents will be required to help them.

Although the project is the kids, the sketch includes the usage of Arduino Interrupt. We have dedicated articles explaining What is Interrupt and How Interrupt Works. This function is used to make the system responsive. If we simply write the code, the button press will be erratic.

The sketch sets up a simple control system where pressing a button toggles the state of a 3V DC pump and updates the state of two LEDs to indicate whether the pump is running or stopped. Using interrupt-based button detection ensures immediate responsiveness to button presses, providing a smooth user experience.

Advertisement

---

 

Required Components For This Project

 

  • 1x Arduino Nano (or another Arduino UNO)
  • 1x Breadboard
  • Few Jumper wires
  • 1x 3V Mini water pump
  • Water pump pipes
  • 1x PN2222 transistor
  • 3x 330 Ohm resistors
  • DC power source, such as battery
  • Computer with Arduino IDE installed

The connection to the 3V mini pump will be like that we have described in Arduino 3V DC Motor Control. You can read that article for information on transistors and diodes for this kind of motor.

 

Connection, Simulation and Sketch

 

Here is the simulation of the project:

Here are the connection details:

Arduino’s PIN 5 will be connected to the pump. Instead of a direct connection to the pump, a transistor has been used.
Arduino’s PIN 2 will be connected to the push button.
Arduino’s PIN 8 will be connected to the green LED indicator.
Arduino’s PIN 9 will be connected to the red LED indicator.

Arduino 3V DC Mini Pump with Push Button Control and LED Indicators

Here is the sketch:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Define pin numbers for components
#define PUMP_PIN 5        // Pin connected to the 3V DC pump
#define BUTTON_PIN 2      // Pin connected to the push button
#define GREEN_LED_PIN 8   // Pin connected to the green LED indicator
#define RED_LED_PIN 9     // Pin connected to the red LED indicator
 
// Define variables to store pump state and LED states
volatile bool pumpRunning = false;
bool greenLedState = LOW;
bool redLedState = LOW;
 
void setup() {
  // Initialize pins
  pinMode(PUMP_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP); // Use internal pull-up resistor
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(RED_LED_PIN, OUTPUT);
 
  // Attach interrupt to the button pin
  attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), buttonPressed, FALLING);
 
  // Turn off pump and LEDs initially
  digitalWrite(PUMP_PIN, LOW);
  digitalWrite(GREEN_LED_PIN, LOW);
  digitalWrite(RED_LED_PIN, LOW);
}
 
void loop() {
  // Update LED states based on pump state
  digitalWrite(GREEN_LED_PIN, greenLedState);
  digitalWrite(RED_LED_PIN, redLedState);
 
  // Check if the pump is running and update LED states accordingly
  if (pumpRunning) {
    greenLedState = HIGH; // Turn on green LED
    redLedState = LOW;    // Turn off red LED
    digitalWrite(PUMP_PIN, HIGH); // Turn on the pump
  } else {
    greenLedState = LOW;  // Turn off green LED
    redLedState = HIGH;   // Turn on red LED
    digitalWrite(PUMP_PIN, LOW);  // Turn off the pump
  }
}
 
// Interrupt service routine for button press
void buttonPressed() {
  // Toggle pump state
  pumpRunning = !pumpRunning;
}

You’ll get the above code from my GitHub repository too. Here is the link.

 

Explanation of the Sketch

 

These lines define the pin numbers for the components connected to the Arduino board:

Vim
1
2
3
4
#define PUMP_PIN 8        // Pin connected to the 3V DC pump
#define BUTTON_PIN 2      // Pin connected to the push button
#define GREEN_LED_PIN 5   // Pin connected to the green LED indicator
#define RED_LED_PIN 6     // Pin connected to the red LED indicator

Vim
1
2
3
volatile bool pumpRunning = false;
bool greenLedState = LOW;
bool redLedState = LOW;

pumpRunning: This variable stores the current state of the pump. It’s declared as volatile because it’s modified inside an interrupt service routine.
greenLedState and redLedState: These variables store the current states of the green and red LEDs, respectively. Initially, both LEDs are set to LOW (off).

Vim
1
2
3
4
5
6
7
8
9
10
11
12
void setup() {
  pinMode(PUMP_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP); // Use internal pull-up resistor
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(RED_LED_PIN, OUTPUT);
  
  attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), buttonPressed, FALLING);
  
  digitalWrite(PUMP_PIN, LOW);
  digitalWrite(GREEN_LED_PIN, LOW);
  digitalWrite(RED_LED_PIN, LOW);
}

pinMode(): Configures the pins as inputs or outputs.
attachInterrupt(): Attaches an interrupt to the button pin (BUTTON_PIN). When the button pin transitions from HIGH to LOW (FALLING edge), the buttonPressed() function is called.

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void loop() {
  digitalWrite(GREEN_LED_PIN, greenLedState);
  digitalWrite(RED_LED_PIN, redLedState);
  
  if (pumpRunning) {
    greenLedState = HIGH;
    redLedState = LOW;
    digitalWrite(PUMP_PIN, HIGH);
  } else {
    greenLedState = LOW;
    redLedState = HIGH;
    digitalWrite(PUMP_PIN, LOW);
  }
}

Continuously updates the states of the green and red LEDs based on their corresponding variables (greenLedState and redLedState).
Checks the pumpRunning variable to determine whether to turn on or off the pump and LEDs accordingly.

buttonPressed() Function (Interrupt Service Routine):

Vim
1
2
3
void buttonPressed() {
  pumpRunning = !pumpRunning;
}

This function is called whenever the button is pressed due to the attached interrupt. Toggles the pumpRunning variable, effectively starting or stopping the pump.

Tagged With diseasemt7
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Arduino 3V DC Mini Pump with Push Button Control and LED Indicators (For Kids)

  • Arduino and LED Bar Display : Circuit Diagram, Code

    Here is a Guide Explaining the Basics, Circuit Diagram, Code on Arduino and LED Bar Display. LED Bar Display is Actually Like Multiple LED.

  • Arduino Door Bell With Push Button With 3 LED

    Here is Circuit Diagram, Code, List of Components & Demonstration Video of Arduino Door Bell With Push Button With 3 LED. It is easy project.

  • Arduino Interrupt: Blink LED and Beep Every 1 Second, Pauses Upon Button Press

    Though the previous few articles, I have explained some theories required for embedded projects, which include three longer articles on Interrupt – What is Interrupt, How Interrupt Works and Understanding Arduino Interrupts. If you have not read those articles and are not sure what I am talking about, then kindly read the three articles after […]

  • Mini Christmas Light With Arduino (Very Easy)

    Here is a Mini Christmas Light With Arduino as Project Which Needs 3 Resisters and 3 LEDs, No External Power Supply. It Has 2 Blink Effects.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy