#define phpump = 3; //ph pump connected to pin 3 (should I use #define??)
Not this way, no.
There are two arguments to the #define function - the name and the value. In this example, the name is "phpump" and the value is "= 3;". Everywhere else that "phpump" occurs, the value will be substituted.
pinmode(phpump, OUTPUT); //sets ph pump as output
will become:
pinmode(= 3;, OUTPUT); //sets ph pump as output
Of course the compiler will complain about this.
int value; //value for reading. Do I need this???
No, you don't.
int inputvariable = 0; //do i need this??
No, you don't.
if (inputvariable <#); //variable more than number 0-1023(i dont know this # yet)
Its val that you want to be comparing, not inputvariable, which has a value of 0. Unless # gets replaced by 0, the test will always succeed.
If it does, though, the body of the if statement is the ; on the end. By itself, ; is a no-operation. So, if inputvariable, or val, when you change the statement, is less than #, do nothing. Otherwise, do nothing. How useful is that? Get rid of the ;.
if else (inputvarible >#); //if varible is below ^
If else? That should be "else if", and inputvariable should be val. What do you propose to do if val is equal to #? What you should have is:
if(val < #)
{
// do one thing
}
else
{
// do the other thing
}
Of course, # needs to be replaced with an actual number.
delay(300000) /delay 5 min before remeasuring. is there a better way???
Literals are interpreted as ints when there is no decimal point, and nothing to indicate otherwise. In this case, there is no decimal point, and nothing to indicate otherwise, so the compiler will happily shove 300000 into an int. Now, this might be a problem, since 300000 wont fit into an int, without a bit of it overflowing.
Since the delay() function takes an unsigned long as its argument, you need to tack UL onto the end of the number to tell the compiler to treat 300000 as an unsigned long, instead of an int.
delay(300000UL) /delay 5 min before remeasuring. is there a better way???
It goes without saying, I hope, that you need a ; and 2 slashes for the comment.
Is there a better way? Yes. Look at the BlinkWithoutDelay example for a clue. Nothing will happen while the delay() function is "executing" (read that as doing nothing for a while).
You can't read the sunlight level and turn on lights, you can't test the temperature of the solution, or any of the myriad other things that you will eventually want to do.
Finally, putting each { and } on lines by themselves, and indenting code between the { and } will make the program much easier to read.
Oh, and look at the logic of your program. If the ph level is low, turn the pump on for 5 second. If the ph level is high, turn the pump on for 1 second. Now, if you were writing instructions for your neighbor to watch your tank while you went on vacation, would you describe what needed to be done this way?
And, last, but not least, comments should describe what the program is going to do, not what it did.
// Turn the pump on if the ph level gets low
if(phLevel < someValue)
{
digitalWrite(pumpPin, HIGH);
}
is far better than:
if(phLevel < someValue)
{
digitalWrite(pumpPin, HIGH); // Turn the pump on
}
Any moron can see that the digitalWrite function has turned the pump on. What we need to know/you need to document is the overall logic of the program, not a step by step description of each statement.