Arduino water pump error

Hi guys.. I got a problem with my water pump 9V. I can not control it, the lcd always shut down and display weird number when it is running. I am newbie on arduino so Im glad if someone can help me.

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.clear();
  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);
  delay(1000);
  lcd.setCursor(0, 0);
  lcd.print("IRRIGATION");
  lcd.setCursor(0, 1);
  lcd.print("SYSTEM IS ON ");
    lcd.print("");
    delay(3000);
  lcd.clear();
}
 
void loop() {
  int value = analogRead(A0);
  Serial.println(value);
  if (value < 300) {
    digitalWrite(2, LOW);
    lcd.setCursor(0, 0);
    lcd.print(" Pump is ON ");
  } else {
    digitalWrite(2, HIGH);
    lcd.setCursor(0, 0);
    lcd.print(" Pump is OFF");
  }
 
  if (value < 300) {
    lcd.setCursor(0, 1);
    lcd.print("Moisture : HIGH");
  } else if (value > 300 && value < 550) {
    lcd.setCursor(0, 1);
    lcd.print("Moisture : MID ");
  } else if (value > 550) {
    lcd.setCursor(0, 1);
    lcd.print("Moisture : LOW ");
  }
}

More info is needed: the complete sketch, and how things are wired. It's ok to do a hand drawn schematic over the wiring too.

Edit: Welcome to the forum btw!

I'm going to guess that you are trying to power your 9V pump from a 9V smoke alarm battery. You have no chance, those batteries are good for powering smoke alarms and not much else. You need a power supply capable of supplying at least the stall current of the pump motor.

1 Like

HI, @aonsojim
Welcome to the forum.

Have you written your code in stages?
Have you got code that just runs ans stops the pump, to prove you have control?

If not, then please leave your main code for the moment and write some code to JUST run and stop the pump.

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.. :grinning: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.