Servo motor and DC pump not working at the same time.

Hi! I am using a micro servo and a dc motor pump with L298 H-bridge. My project needs both of them to work at regular intervals. When I test them separately, they work perfectly. However, when I merge the codes, only the servo motor works and the dc pump does not work.
I am making an automatic pet feeder and the servo will help deliver the food while the pump is for water. Right now, I am reducing the delay to about 3 seconds.
Please help me!

Project.ino (375 Bytes)

How is everything wired up? Often, servo problems relate to power and the Arduino can't provide enough. Do you have a separate power supply for the servo and motor?

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

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

What are you using go power your project?

Thanks.. Tom.. :slight_smile:

wildbill:
Often, servo problems relate to power and the Arduino can't provide enough.

A rather odd way to phrase things. :astonished:

An Arduino cannot provide any power - it is not a power supply, it is a microcontroller module!

#include <Servo.h>
int ena = 9;
int i;
Servo qservo;
void setup(){
  // set all the motor control pins to outputs
 
  pinMode(ena, OUTPUT);
  qservo.attach(6);
  qservo.write(0);
 
}
void loop()
{
  while (i<=3){
  analogWrite(ena,100);
  qservo.write(90);
  delay(1000);
  analogWrite(ena,0);
  qservo.write(-90);
  delay(3000);
  i++;
  
  }


}

It always pays to read the documentation

qservo.write(-90); What's that?

the code counts to 4, then does not reset.

after the count reaches 4 it never feeds or waters again until you reset the power.

It would seem that "BlinkWithoutDelay" would allow you to put in longer time periods and then reset after you fed and watered.

...and don't forget to reflect the wiring changes in the code.

Sorted now. Thanks everyone!