can someone check my code

can someone check my code?
this is my final year project. pleaase some help?
all the component is functioning but the water pump did not pump the water out.
for your imformation, the water pump is working but why water not coming out?

try_and_error.ino (1.11 KB)

If the code works and the pump works:
Does your pump, pump water if you just hook it to a battery.

Show us a schematic.

Show us a picture of you wiring.

Why not simply post the code, so that people on tablets and phones can see it?

int led1 = 9;  //led1(green led)
int led2 = 10; //led2(red led)
int pumpAnodePin =  6;     
int pumpCathodePin =  7; 
int wateringtime=10;
int wateringstop=50;

void setup() 
{ 
  Serial.begin(9600); 
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(pumpAnodePin, OUTPUT);
  pinMode(pumpCathodePin, OUTPUT);
} 
void loop() {
  
  int sensorValue = analogRead(A0); 
  Serial.println(sensorValue);
  delay(100);     
  
  if (sensorValue >= 988)
  {
    digitalWrite (led1, LOW);
    digitalWrite (led2, HIGH);
    delay(wateringtime);
    digitalWrite (pumpAnodePin, HIGH);
    digitalWrite (pumpCathodePin, LOW);
    delay(50);
  }
  else if (sensorValue >= 329 && sensorValue < 988)
  {
    digitalWrite(led1, HIGH);
    digitalWrite(led2, LOW);
    delay(wateringtime);
    digitalWrite (pumpAnodePin, HIGH);
    digitalWrite (pumpCathodePin, LOW);
    delay(50);
  }
  else if (sensorValue >= 289 && sensorValue < 329)
  {
    digitalWrite(led1, HIGH);
    digitalWrite(led2, LOW);
    delay(wateringstop);
    digitalWrite (pumpAnodePin, LOW);
    digitalWrite (pumpCathodePin, LOW);
    delay(50);
  }
  delay(1000);
}

newbiengineer:
the water pump is working but why water not coming out?

That sounds like a plumbing problem rather than a programming problem.

Some pumps need to be primed.

Is it possible the pump is running backwards - i.e. wired incorrectly ?

...R

Is there any liquid in whatever the pump is pumping from ?

Why are you connecting the pump to two digital pins? You should be connecting it to ONE digital pin and ground.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Are you trying to supply the pump with power directly from the arduino controller?

It is very important that we see a circuit diagram.

Tom.... :slight_smile: