I need help with my code for a Mini Air Pump

Hey!
I am working on a major project for my final year systems engineering class and I am using a miniature air pump.
I'm having a little trouble writing code though. I have the basic functions working; the pump pushing air out and the pump sucking air back. The pump I am using has the ability to do both off of one. Here's a link to it: Air Pump and Vacuum DC Motor - 4.5 V and 2.5 LPM [ZR370-02PM] : ID 4699 : $7.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Basically, I can use both actions. But I'm unsure how to swap between the two. I will link my code below, but I am using the "delay()" line trying to get the pump to stop pushing air to then sucking it. But they are just both going at the same time.

PLEASE HELP!!!

Code example I am using:

const int pumpPin =  9;   
 
void setup() {
  pinMode(pumpPin, OUTPUT);
}
 
void loop() {
    digitalWrite(pumpPin, HIGH);  
    delay(5000);                   
    digitalWrite(pumpPin, LOW);    
    delay(5000);              
}

Hello archwillo

Welcome to the worldbest Arduino forum ever.

Post some pictures of the hardware setup and a timing diagram showing what shall happens under which give circumstances.

Have a nice day and enjoy coding in C++.

You can't switch between the two.
It will always do both.
You need TWO pumps and/or a control valve to switch between the two functions.

This is my setup for the first 'prototype' of what will be 5 of these lined up.
The image below is just a nicer way of looking at it, and the "Transistor" connected is a MOSFET. As of right now I have no 'diode' in the system thinking it is irrelevant to what I am trying to achieve. And instead of the battery in the digital diagram, I am using the 5V pin on the Arduino Uno itself.
(FYI that pump in the picture is not what I am using, rather another example of simple one way directional air flow. Thus I have altered it).

Could you also please elaborate on what you mean by the diagram.
If you need anything else please let me know.

Thanks heaps for your swift response! Means a lot.
image

@archwillo
You can't switch between the two.
It will always do both.
You need TWO pumps and/or a control valve to switch between the two functions.

1 Like

Hello,

At first: you'll need the diode to protect the MOSFET, except, it'll have this diode integrated (=> datasheet). The motor (coil) of the pump can generate high voltage and this can destroy the MOSFET and the Arduino as well. And I'm quite sure, you don't want that. :thinking:

Then, you'll need two pumps. one, that will fill the balloon with air, the other pump to evacuate it. as an alternative, you can use a 3-way magnetic valve and one pump. but this is more tricky. I would recommend the setup from Adafruit.

Regards,
Tom

Thanks you!

You are right, I would much rather keeping my MOSFET and NOT having it blow up in my face (or at least it would be cooler to blow up rather than sizzle and fry). I'll definitely invest in a second pump as well as a valve.

Thanks heaps for your time!

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