I'm measuring the sunlight and my LCD screen is supposed to on when it is bright and off when it is dark.With this code I have no problem measuring light.LCD is on when it is bright but when I darken my LDR, LCD does not turn off, it stays on.Am i missing something here?
If your LDR is reading (from analogRead(), assuming the typical connections) <15 in darkness and 40 in sunlight the resistor in series with it is probably the wrong value, or something else is wrong. How is it wired?
-Resistor is 10k. I read <4 when it is dark. 15 is threshold value that I chose.If I'm not mistaken 40 is from Serial.println(int(Light(analogRead(0))));.
Change of values in serial port is matching according to light intensity, I think there is no problem with that.
-Right now I use LED instead of LCD screen seen in picture for easier test.
Personally, I don't think it makes any sense to print the value returned by the function when that is NOT the value used in the rest of the code. Print what you ACTUALLY use.