Arduino Coding for 2 Pumps alternating on/off

Hey everyone! :slight_smile:

I’m completely new to coding and I am in dire need of some professional assistance! 8)

I am trying to code an Arduino to control 2 mini 12V water pumps. I am trying to code it so the first pump will go for 5 seconds then stop, when the second pump will start and go for 5 seconds then stop and continues on a loop.

I’ve been trying to manipulate this code, but to no avail:

int motorPin = 3;

void setup()

{

pinMode(motorPin, OUTPUT);

Serial.begin(9600);

while (! Serial);

Serial.println(“Speed 0 to 255”);

}

void loop()

{

if (Serial.available())

{

int speed = Serial.parseInt();

if (speed >= 0 && speed <= 255)

{

analogWrite(motorPin, speed);

}

}

}

The details to the 2 pumps:

• Rated Voltage: 12V

• Working Voltage: 6-15V (Maximum 18V)

• Rated Current: 1.2A

• Maximum Lift: 5M

• Maximum Flow Rate: 840L/Hour

• Use it on 6V-15V, otherwise the Water Pump will be burning-out

Can anyone please please help me?

brynnaa:
I’m completely new to coding and I am in dire need of some professional assistance!

Professional?

For 2x 5 second loops?

Know what a “Professional Software Engineer” costs?

I charge upwards of $100/HR.

Know what code tags can do for you?

Try it with some LEDs first to see if it really works? Or hook it directly up to a couple of 12V motors?

Trying to run those 12V motors from a 5V Arduino board?

Have random wires hooked up to random connections?

Nobody can really know. No schematic anywhere. Not even a ‘back of the napkin’ drawing.

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
}

void loop()
{
  digitalWrite(2, HIGH);
  delay(5 * 1000);
  digitalWrite(2, LOW);

  digitalWrite(3, HIGH);
  delay(5 * 1000);
  digitalWrite(3, LOW);
}

You’ll also need something like https://www.sparkfun.com/products/11214 between the Arduino and each of the motors.