Vacuum Pump Coding issue

Hello everyone,

I am working on my final degree show for my masters and I am stuck in the coding part. I am building up a fake “lung" that it’s breathing on its own. I would like to add a sensor, so when it detects someone approaching closer to the whole object, the breath rhythm rises. To develop it, I am working with a couple of vacuum pumps (they inflate and deflate the “lung") and a microcontroller that contains the code that automates the process. As I am not coming from an engineering background, and I only have basic knowledge of Arduino, I used a simulator to develop the circuit and a basic code: How to wire Vacuum Pump - 12V, Vacuum Pump - 12V, Infrared Proximity Sensor Long Range - Sharp GP2Y0A02YK0F to Arduino Mega

The code that the simulator created is based on a “Menu option” mode, in which I have to select a Pin (linked to a vacuum pump) in order to test it. I uploaded it to my microcontroller and it seemed to work. So I tried to rewrite it, disabling the menu option and automating the action of the two vacuum pumps working alternatively (when one is on the other one is off, and viceversa), and adding the proximity sensor, however it doesn’t seem to work. There’s no menu option this time but there’s something missing that doesn’t activate the air pump.

Here I attach all the information with regards to the electronics:

2 Vacuum pumps
1 Microcontroller Arduino UNO
2 MOSFET transistors 60V 30A
1 Wall Power Adapter supply 12V
2 10K 0hm Resistors
1 Proximity Sensor
Breadboard and wires

Also, I provide pictures of the installation, the main code I downloaded, ‘Firmware’, and the one I rewrote, ‘Breathe’.

Thank you so much for helping me out, any kind of idea will be appreciated.

Breath.zip (19.8 KB)

Firmware.zip (19.8 KB)

Most forum members read the forum on phones & tablets, so can't open .zip files or .ino files. Post your code according to the forum guide in the sticky post and also include your schematic diagram and links to the various components like the MOSFETs, pumps and sensor (no need for a link to the Uno or resistors!).

I will do you a favour by posting your pictures.

Have you considered how much current can the conductor in the breadboard supply?

Have you looked at the number of how much current that Arduino Uno pin can supply?

You are doing a comparision in several places vs. an assignment

    if (menuOption == '2') {
      // Vacuum Pump - 12V #1 - Test Code
      // The water pump will turn on and off for 2000ms (4 sec)
      vaccumpump_1.on(); // 1. turns on
      delay(2000);       // 2. waits 500 milliseconds (0.5 sec).
      vaccumpump_1.off();// 3. turns off
      delay(2000);       // 4. waits 500 milliseconds (0.5 sec).
      menuOption == '3';

That last line should be menuOption = '3' since you want to set the value. Your code currently just compares the two and throws away the results.

This mistake is in several places throughout your code.