It seems like this has worked before but now I am uncertain about the current results:
boolean variable = digitalRead(pin);
as in:
IsWater = digitalRead(ReadFloatPin);
Thanks
It seems like this has worked before but now I am uncertain about the current results:
boolean variable = digitalRead(pin);
as in:
IsWater = digitalRead(ReadFloatPin);
Thanks
The digitalRead() function returns an int, containing one of two values - HIGH or LOW. LOW is defined as 0, while HIGH is defined as 1. Coincidentally, these are the same values assigned to false (LOW) and true (HIGH).
I usually do it as
byte variable = digitalRead (pinName);
Then value is always 0 or 1, good for doing other operations if needed.
And only 1 byte of memory as far as I know.
With boolean, result is technically 0 or not 0, which is fine if just looking for a True/False answer.
Int? Byte? I don't know, will trust PaulS on that.
Thanks, the byte variable sounds like a good solution. I think it was salvation once before when things seemed to become flaky, but I cannot find the code
Thanks, the byte variable sounds like a good solution.
That's probably the best choice, since a boolean is the same size as a byte.
I tried both. The results seem to be the same. The underlying problem proved to be a misplaced } that caused some code to be included in an else .
Thanks again