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!
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?
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?
#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++;
}
}