Slow response - how to improve . . ?

Hello to all,

I would like to state that im still a noob and trying to learn as much as it needs to continue my progress with the Arduino.

Thanks for your prompt reply, i appreciate all your comments, that make me more motivated to go on further to improve my code and learn more and more. Thanks again. . :wink:

PaulS:
You could read the switch state after each call to SoilMoistureN().

Im i correct, if in the void loop, i place the SwapMenu() after each MoistureN = SoilMoistureN(); ? I.e using in all 4 SwapMenu(); ??

Why do you need 4 nearly identical functions. One would do, if the pin numbers were passed in. Then, you could call the one function in a for loop, testing the switch state after each iteration.

Im actually testing the soil moisture percentage for 4 different variety of plants, i shall conclude if they consume almost the same amount of water per day.

According to what you said about passing the pin numbers and calling a for loop, can you kindly please explain a little more so that i can grasp the max and try to implement it.

The SwapMenu() code is ridiculous. Testing to see what value lcdMode has before incrementing it is silly. Just increment is, whatever value it has. Then, test to see if it is out of range. Fix it, it if is.

I shall try to perform this increment algorithm, will keep thing posted to see if im on the right track.

robtillaart:
Also the use of arrays can simplify the code as you have four times the same measurements.

int SoilMoisture(int i) is a function that needs to be rewritten to but with the above +
the info about arrays in the tutorial section you should be able to figure it out.

I Shall consult the array tutorial and come back here for clarifications if needed, and im sure i will need those.

michinyon:
Well your lux calculation is wrong, for a start.

You need to re-read the description of how the light-sensitive device works, and how it is approximately
linear on a log-log scale. It's the last bit of that sentence, I think you didn't understand.

It seems i did not much understand the linear on a log-log scale, but i presumed it was for data logging, and i wrong, can you please guide me on this issue.

Thanks