Go Down

Topic: Slow response - how to improve . . ? (Read 2 times) previous topic - next topic

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.

taz3m

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. .  ;)


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(); ??

Quote

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.

Quote

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.


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.


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
tz
.....

Nick Gammon


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


The "increment algorithm"? As in, adding one to a variable?

taz3m

Hello,

I have been through the tutorial for Arrays and For loop, that indeed will simplify several things.

Im in the process of rewriting my code, i shall keep things posted to know if im on the right track.

Can you please clarify these for me :

Code: [Select]


lcd.print(i, DEC);

lcd.print(PercentMoisture[i], 1);


Thanks

taz . .
tz
.....

PaulS

Quote
Can you please clarify these for me :

Sure. You tell us what is not clear, and we'll clear that up.

Go Up