I have connected my LDR between A0 and 3volts on my board and a 10k resistor between 3volts and ground, as i have seen on a schematic,
but i only get high values, its giving 1024 even in low light and it only goes down to 600 even if i cover it,
i tried to change the resistor to 3.3k ohms but its still the same.
is there a problem with the sensor or the resistor value?
Your schematic is wrong if it shows those connections.
Make it look like this:
Then try reversing the positions of the 10K resistor and the LDR. What happens then?
Ron
Or for a simple test, connect the LDR from analog input to ground. Set the pinMode of the input to INPUT_PULLUP to enable the internal pullup resistor. Then no external resistor is needed.
example of LDR on input pullup analog input pin:
const byte ldrPin = A0;
void setup()
{
Serial.begin(115200);
Serial.println("LDR Test Program");
pinMode(ldrPin, INPUT_PULLUP);
}
void loop()
{
static unsigned long timer = 0;
unsigned long interval = 1000;
if (millis() - timer >= interval)
{
timer = millis();
int ldrReading = analogRead(ldrPin);
Serial.print("ldr reading = ");
Serial.println(ldrReading);
}
}
Reads low numbers when in light, high when dark. Often when using the internal pullup the sensitivity is OK, but if not then use an external resistor.
but i only get high values, its giving 1024 even in low light and it only goes down to 600 even if i cover it,
So you need to drop the value of the resistor in the circuit shown in reply #2.
For best results measure the resistance of the LDR in the mid light level you want and make the resistor as close to this value as you can.
szevlin:
I have connected my LDR between A0 and 3volts on my board and a 10k resistor between 3volts and ground, as i have seen on a schematic,
but i only get high values, its giving 1024 even in low light and it only goes down to 600 even if i cover it,
i tried to change the resistor to 3.3k ohms but its still the same.
is there a problem with the sensor or the resistor value?
Try the resistor between A0 and gnd, with the LDR between 3V and A0.
Tom...