I've followed alot of tutorials on google for this very simple project. After switching from a 10k to 4.7k resistor commonly used I am now getting 66 under complete luminosity (this value sometimes fluctuates between 65 - 67 ??) and around 390 in darkness on A0. However I am expecting to get 0-1023. I have made sure all the connections are going to the right place could someone please explain how it's possible to get the full range of 0-1023?
int LDR_Pin = 1; //analog pin 0
void setup(){
Serial.begin(9600);
}
void loop(){
int LDRReading = analogRead(LDR_Pin);
Serial.println(LDRReading);
delay(250); //just here to slow down the output for easier reading
}
It depends on the LDR.
Most LDRs have a resistance of hundreds of kilo ohms or Mega ohms in darkness.
That would result in a value of about 1023 (or close to it).
Are you sure you have a LDR ?
Could you try another LDR ?
Could you try another analog input ?
Do you use a breadboard ? Try other connections, they have sometimes bad contacts.
Do you have a multimeter to read the actual voltage over the LDR ?
Do you have the pull-up resistor connected to +5V ? Could you measure that with a multimeter ?
thanks for the response Erdin, I understand there are many factors that can cause problems with such elemental issues.
After switching back to a 10k Ohm pull resistor in the circuit and using
float voltage= sensorValue * (5.0 / 1023.0);
voltage = 0.35 (full brightness)
voltage = 1.40 (in darkness)
voltage = 5.00 (LDR removed from circuit)
I have tired 4 different LDRs which I got shipped with the Arduino starter kit on the different analog ports and get near enough the same kind of readings. so I suppose it has something to do with the LDR itself?