# My Water Pump Doesnt Work

**URL:** <https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190>\
**Category:** General Guidance\
**Created:** [September 4, 2023, 1:08pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190 "2023-09-04T13:08:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 4, 2023, 1:08pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/1 "2023-09-04T13:08:37Z")

</div>

```arduino
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

int lastButtonState = HIGH;
int lastButtonStateLess = HIGH;
int lastButtonStateTarget = HIGH;
int buttonState = HIGH;
int buttonStateLess = HIGH;
int buttonStateTarget = HIGH;
unsigned long lastDebounceTime;
unsigned long lastDebounceTimeLess;
unsigned long lastDebounceTimeTarget;
int debounceDelay = 50;
int count = 0;
int AA = 10; 
int AB = 6;

int moisture;
int sensorinput;
int sunlight;
float temp;

float moistLimit = 463.5; // Add by 51.5
unsigned int tempLimitMin = 18;
unsigned int tempLimitmax = 29;
float lightOneLimit = 150.0;
float lightTwoLimit = 100.0;

int changetarget = 0; // Target: 1 = Moisture 2 = Temperature Min 3 = Temperature Max

unsigned long updateTime;

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);
  pinMode(8, INPUT_PULLUP);
  pinMode(9, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(2, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(AA, OUTPUT);
  pinMode(AB, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(A2, INPUT);

  lcd.init();
  lcd.backlight();
  lcd.clear();
}

// the loop function runs over and over again forever
void loop() {
  // Moisture Code
  moisture = analogRead(A0);
  if (moisture >= moistLimit) {
    digitalWrite(2, HIGH);
    digitalWrite(AA, HIGH);
    digitalWrite(AB, LOW);
  }
  else {
    digitalWrite(2, LOW);
    digitalWrite(AA, LOW);
    digitalWrite(AB, LOW);
  }
  
  // Temperature Code (TMP36)
  sensorinput = analogRead(A1);
  float voltage = sensorinput * (5.0 / 1024.0);
  temp = (voltage - 0.5) * 100;

  if (temp > tempLimitmax || temp < tempLimitMin)
  {
    digitalWrite(12, HIGH);
  }
  else
  {
    digitalWrite(12, LOW);
  }

  //Sunlight Code
  sunlight = analogRead(A2);
  
  //DEBUGGING USE
  
  if (sunlight <= lightOneLimit) {
    digitalWrite(4, HIGH);
    
    
    if (sunlight <= lightTwoLimit) {
      digitalWrite(5, HIGH);
    }
  }
  else {
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
  } 

  // Button Code
  // Increase Button
  int pinValue = digitalRead(9);

  if (pinValue != lastButtonState)
  {
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay)
  {
    if (pinValue != buttonState)
    {
      buttonState = pinValue;
      
      if (buttonState == LOW)
      {
        digitalWrite(13, HIGH);

        switch (changetarget)
        {
          case 1:
            {
              moistLimit += 51.5;
            }
            break;
          case 2:
            {
              tempLimitMin += 1;
            }
            break;
          case 3:
            {
              tempLimitmax += 1;
            }
            break;
          case 4:
            {
              lightOneLimit += 50.0;
            }
            break;
          
          case 5:
            {
              lightTwoLimit += 50.0;
            }
            break;
        }
      }

      else
      {
        digitalWrite(13, LOW);
      }
    }
  }

  lastButtonState = pinValue;

  // Decrease Button
  int pinValueLess = digitalRead(8);

  if (pinValueLess != lastButtonStateLess)
  {
    lastDebounceTimeLess = millis();
  }

  if ((millis() - lastDebounceTimeLess) > debounceDelay)
  {
    if (pinValueLess != buttonStateLess)
    {
      buttonStateLess = pinValueLess;
      
      if (buttonStateLess == LOW)
      {
        digitalWrite(13, HIGH);

        switch (changetarget)
        {
          case 1:
            {
              moistLimit -= 51.5;
            }
            break;

          case 2:
            {
              tempLimitMin -= 1;
            }
            break;

          case 3:
            {
              tempLimitmax -= 1;
            }
            break;
          
          case 4:
            {
              lightOneLimit -= 50.0;
            }
            break;
          
          case 5:
            {
              lightTwoLimit -= 50.0;
            }
            break;
        }
      }
      else
      {
        digitalWrite(13, LOW);
      }
    }
  }

  lastButtonStateLess = pinValueLess;
  
  // Change Target Button
  int pinValueTarget = digitalRead(7);

  if (pinValueTarget != lastButtonStateTarget)
  {
    lastDebounceTimeTarget = millis();
  }

  if ((millis() - lastDebounceTimeTarget) > debounceDelay)
  {
    if (pinValueTarget != buttonStateTarget)
    {
      buttonStateTarget = pinValueTarget;
      if (buttonStateTarget == LOW)
      {
        digitalWrite(13, HIGH);
        changetarget += 1;
        if (changetarget > 5)
        {
          changetarget = 0;
        }
      }
      else
      {
        digitalWrite(13, LOW);
      }
    }
  }

  lastButtonStateTarget = pinValueTarget;
  
  if (millis() - updateTime >= 500ul)
  {
    updateTime = millis();
    updateLCD();
  }
}

void updateLCD()
{
  switch (changetarget)
  {
    case 0:
    {
        lcd.setCursor(0, 0);
        lcd.print("Moist Temp Sun");
        lcd.setCursor(0, 1);
        lcd.print(" ");
        lcd.setCursor(0, 1);
        lcd.print(moisture);
        lcd.setCursor(6, 1);
        lcd.print(round(temp));
        lcd.setCursor(11, 1);
        lcd.print(sunlight);
      }
      break;
    case 1:
      {
        Serial.println(moistLimit);
        lcd.setCursor(0, 0);
        lcd.print("Mode 1 ");
        lcd.setCursor(0, 1);
        lcd.print(" ");
        lcd.setCursor(0, 1);
        lcd.print(moistLimit);
      }
      break;

    case 2:
      {
        Serial.println(tempLimitMin);
        lcd.setCursor(0, 0);
        lcd.print("Mode 2 ");
        lcd.setCursor(0, 1);
        lcd.print(" ");
        lcd.setCursor(0, 1);
        lcd.print(" ");
        lcd.setCursor(0, 1);
        lcd.print(tempLimitMin);
      }
      break;

    case 3:
      {
        Serial.println(tempLimitmax);
        lcd.setCursor(0, 0);
        lcd.print("Mode 3 ");
        lcd.setCursor(0, 1);
        lcd.print(" ");
        lcd.setCursor(0, 1);
        lcd.print(tempLimitmax);
      }
      break;
    
    case 4:
      {
        Serial.println(lightOneLimit);
        lcd.setCursor(0, 0);
        lcd.print("Mode 4 ");
        lcd.setCursor(0, 1);
        lcd.print(" ");
        lcd.setCursor(0, 1);
        lcd.print(lightOneLimit);
      }
      break;
    
    case 5:
      {
        Serial.println(lightTwoLimit);
        lcd.setCursor(0, 0);
        lcd.print("Mode 5 ");
        lcd.setCursor(0, 1);
        lcd.print(" ");
        lcd.setCursor(0, 1);
        lcd.print(lightTwoLimit);
      }
  break;
  }
}

```

Whenever I have pinModes for the water pump pins (aka. AA, AB) my water pump doesn't run. However, when I remove the pinModes, the pump starts working, but pin 12 led starts blinking slightly.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [September 4, 2023, 1:18pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/2 "2023-09-04T13:18:38Z")

</div>

Describe the functions of your project.

Post a schematic, hand drawn is fast and easy.

Show all parts and how you've connected them, with attention to sources of power and how that is wired to the parts that need power.

What is pin 12 used for?

a7

---

<div class="post-metadata">

**Author:** ![lastchancename](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/lastchancename/32/215426_2.png) [@lastchancename](https://forum.arduino.cc/u/lastchancename)\
**Post date:** [September 4, 2023, 1:23pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/3 "2023-09-04T13:23:08Z")

</div>

You do know that you can ‘name’ the pins rather than referring to them by number.

It makes your code a lot easier to read.

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [September 4, 2023, 1:37pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/4 "2023-09-04T13:37:19Z")

</div>

@joemamaandarduino  
Which Arduino are you using?

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [September 4, 2023, 4:48pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/5 "2023-09-04T16:48:38Z")

</div>

> [@joemamaandarduino](#):
>
> Whenever I have pinModes for the water pump pins (aka. AA, AB) my water pump doesn't run. However, when I remove the pinModes, the pump starts working, but pin 12 led starts blinking slightly.

Post the complete sketch of both code-versions:

You should post the **complete** sketch of the code-version that makes the pump run  
and  
post the **complete** sketch of the code-version where the pump does not work

and post a schematic. It is very very **very** that a pump starts working if you remove

```arduino
  pinMode(AA, OUTPUT);
  pinMode(AB, OUTPUT);

```

It is very likely that there is something wrong with the wiring.

best regards Stefan

---

<div class="post-metadata">

**Author:** ![bluejets](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bluejets/32/1013044_2.png) [@bluejets](https://forum.arduino.cc/u/bluejets)\
**Post date:** [September 4, 2023, 10:25pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/6 "2023-09-04T22:25:41Z")

</div>

Get the pump working with some simple code first and build from there.

---

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 4, 2023, 11:33pm UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/7 "2023-09-04T23:33:21Z")

</div>

Yep got the simple code. However, it still doesnt work. Im making a diagram for my project rn

```arduino
const int waterPumpA = 6;
const int waterPumpB = 10;

void setup() {
  Serial.begin(9600);
  pinMode(waterPumpA, OUTPUT);
  pinMode(waterPumpB, OUTPUT);

}

void loop() {
  digitalWrite(waterPumpA, HIGH);
  digitalWrite(waterPumpB, LOW);
  delay(5000);
  digitalWrite(waterPumpA, LOW);
  digitalWrite(waterPumpB, LOW);
  delay(5000);

}

```

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [September 5, 2023, 12:08am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/8 "2023-09-05T00:08:08Z")

</div>

Are you driving pumpA backwards?

---

<div class="post-metadata">

**Author:** ![bluejets](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bluejets/32/1013044_2.png) [@bluejets](https://forum.arduino.cc/u/bluejets)\
**Post date:** [September 5, 2023, 8:46am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/9 "2023-09-05T08:46:04Z")

</div>

> [@joemamaandarduino](#):
>
> Yep got the simple code. However, it still doesnt work.

Circuit diagram and photos of all your setup please.

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [September 5, 2023, 8:53am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/10 "2023-09-05T08:53:54Z")

</div>

Hi, @joemamaandarduino

What model Arduino are you using?

Tom.. 😀 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 5, 2023, 10:23am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/11 "2023-09-05T10:23:31Z")

</div>

uno r3

---

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 5, 2023, 10:46am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/12 "2023-09-05T10:46:14Z")

</div>

![schematic](https://europe1.discourse-cdn.com/arduino/original/4X/c/1/8/c18a9ad9f8e51648dd968b89c20e5dc5085ee6ca.png)  
got what you people always wanted

---

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 5, 2023, 10:49am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/13 "2023-09-05T10:49:27Z")

</div>

For the pump and motor driver, I used a L298N and a normal pump

---

<div class="post-metadata">

**Author:** ![StefanL38](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/stefanl38/32/713548_2.png) [@StefanL38](https://forum.arduino.cc/u/StefanL38)\
**Post date:** [September 5, 2023, 10:53am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/14 "2023-09-05T10:53:41Z")

</div>

can you please use such a schematic

> [@How to provide an easy to read schematic and how not](https://forum.arduino.cc/t/how-to-provide-an-easy-to-read-schematic-and-how-not/989506/1):
>
> This tutorial shall show how to provide an easy to read schematic of your wiring and how you should not post fritzing pictures don't post frizzy-pictures like that! if you look at this pictures please tell me the IO-pin-numbers! What ?? You can't read the IO-pin-numbers? You have to download the picture and than zoom in. Don't you have time? You have to download the datasheet of the chip and then look up which pin is connected to what. take additional time to count through the chip-pins an…

or at least add to your existing graphic which pin is what on the L298  
You are loading extra work on the shoulders of other users without giving that information.  
other users will have to lookup the datasheet of the L298N to find out what pin is what.

It is unlikely that you get helpful answers if you put such extraworks onto the shoulders of other users

The answers will typically be  
"check if you wired the L298N to the correct pins"  
"check if you connect all nescessary pins of the L1298N"

What do you think do these two hints really help?

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [September 5, 2023, 11:14am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/15 "2023-09-05T11:14:45Z")

</div>

Does the simulation work?

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [September 5, 2023, 11:19am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/16 "2023-09-05T11:19:25Z")

</div>

The L298N does not come in a 16 pin DIP.  
Did you mean L293D?

---

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 5, 2023, 11:45am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/17 "2023-09-05T11:45:01Z")

</div>

![schematichand](https://europe1.discourse-cdn.com/arduino/original/4X/b/4/8/b48718c42d8bdeac4901d2610d495fab90e599c5.png)  
is this better?

---

<div class="post-metadata">

**Author:** ![TomGeorge](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tomgeorge/32/215261_2.png) [@TomGeorge](https://forum.arduino.cc/u/TomGeorge)\
**Post date:** [September 5, 2023, 11:46am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/18 "2023-09-05T11:46:18Z")

</div>

> [@joemamaandarduino](#):
>
> got what you people always wanted

Please reverse engineer your project.  
Can you please post a copy of your circuit a picture of a hand drawn circuit in jpg, png?  
Hand drawn and photographed is perfectly acceptable.  
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.. 😀 👍 ☕ 🇦🇺

---

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 5, 2023, 11:46am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/19 "2023-09-05T11:46:34Z")

</div>

Sorry... This is my second question in the forum...

---

<div class="post-metadata">

**Author:** ![joemamaandarduino](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@joemamaandarduino](https://forum.arduino.cc/u/joemamaandarduino)\
**Post date:** [September 5, 2023, 11:50am UTC](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190/20 "2023-09-05T11:50:05Z")

</div>

![IMG_1208](https://europe1.discourse-cdn.com/arduino/original/4X/3/2/2/322999e90e61544ef55709af1ae429e4c757f10e.jpeg)  
 ![IMG_1207](https://europe1.discourse-cdn.com/arduino/original/4X/a/9/2/a923ca251321fea5c5c53d1b8d466f15618ac9a6.jpeg)  
 ![IMG_1206](https://europe1.discourse-cdn.com/arduino/original/4X/b/d/5/bd58297aee1912a39da73ca84e35364f53b907b0.jpeg)  
 ![IMG_1205](https://europe1.discourse-cdn.com/arduino/original/4X/a/6/a/a6aac2f9f3ef02da7f9bd43f2fe2e8043274e727.jpeg)  
 ![IMG_1204](https://europe1.discourse-cdn.com/arduino/original/4X/a/b/e/abe36ff02cf2f3feb2716f270213c1804e052fd3.jpeg)

[Next page](https://forum.arduino.cc/t/my-water-pump-doesnt-work/1165190.md?page=2)
