Trying to pass numbers through to a new function....

I am writing a code where I want a function to pass numbers through to a different called function. The code is for mixing nutrients. The three numbers I want to pass to a function are the amount of nutrient to pump, the peristaltic pump calibration factor and which pump to turn on.

      pumpit(cma, cmcal, calmag);
      pumpit(n1a, n1cal, n1);
      pumpit(n2a, n2cal, n2);
      pumpit(n3a, n3cal, n3);
      pumpit(n4a, n4cal, n4);
      pumpit(n5a, n5cal, n5);
      pumpit(n6a, n6cal, n6);
      pumpit(n7a, n7cal, n7);
      loop();
    }
  }
}

void pumpit(x, y, z) {
  if (x == 0) { //if amount is zero do nothing
    return;
  }
  noInterrupts();
  val = x / y; //total amount / calibration factor
  digitalWrite(mix, HIGH); //a circulation pump in the reservoir
  digitalWrite(z, HIGH); // turn on peri pump
  delay(val); // delay by calculated calibration factor
  digitalWrite(z, LOW); // turn off peri pump
  digitalWrite(mix, LOW); //turn off circulation pump
  interrupts();
}

I have declared "x", "y" & "z" as int variables. Will this work how I want it to? What am I doing wrong here?

ZakAttack92:
I have declared “x”, “y” & “z” as int variables.

No you haven’t:

void pumpit(x, y, z) {

Please post a full code that actually compiles.

here is the full code

Nute_Mixer.ino (14.5 KB)

A quick read of the compiler's error messages shows:

  • ‘ph’ is declared as both a global int and a function.

  • ‘flushit’ and ‘pumpit’ don’t have data types specified for their formal parameters.

  • The symbol ‘phsens’ is undefined -- hint C / C++ is case sensitive.

  • The symbol ‘ecsens’ is undefined.

  • You’re calling ‘adjustph(phsv)’, but that function is defined to take no arguments.

  • The symbol ‘cmc’ is not defined.

Okay, I changed the function ph to be phl so that should take care of the duplicate naming.
What does that tell us? I defined a data type wrong? What needs to be done to remedy this?
I thought the phsensor was defined by this line at the top of my code:

#define PHsens 1

ecsens is something I was thinking of adding in the future, meant to comment it all out. Fixed.
What I am trying to do with “adjustph(phsv)” is pass data to that function. This was my original question of is this correct and if not how do I properly pass data between functions?

Nute_Mixer.ino (14.5 KB)

#define PHsens 1
pinMode(phsens, INPUT);

See the difference? Hint (AGAIN) C/C++ is case sensitive.

Have a read: https://www.arduino.cc/en/Reference/FunctionDeclaration

Went through that article and made a few changes. According to the bottom error reporting I don’t think there are any programming errors but it is still not compiling. Any suggestions on this modified code?

Nute_Mixer.ino (14.6 KB)

which is the liquidcrystal lib your are using ? i can't check without it.

One line in the 'flushit()' function is missing a ';'.

Wow it finally compiles! Thank you so much for your help! Time for me to get to debugging as I'm sure im going to be doing a ton of that.