I am relatively new to arduino projects, and are wondering what is the problem. When I try to test out the LDR by using the code below, it is outputting as low digits. When there are no lights, it hits 0, but under a large amount of light only makes it rise up it ~25. Why is it hitting a max of ~25 when the max is 1024? There are no error messages when verifying the code, and the ram usage in the arduino is fine.
The LDR has a resistance of 0.2 mΩ
The Resistor has a resistance of 22k Ω
The attachment below has the fritzing schematics of our setup.
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A1);
// print out the value you read:
Serial.println(sensorValue);
delay(30); // delay in between reads for stability
}
You need to take the LDR out and measure it’s resistance under the lighting conditions you want .
Then calculate a resistor value to give higher readings from the Arduino .
Google “resistor divider “ and with a 5v supply ; experiment with values until you get a voltage range nearer what you want .
arduin_ologist:
Interesting wiring colour code: red for ground and blue for 5V?
Yes I found this sort of confusion in foreign students when I lectured at a UK university. It is so ingrained in western culture, this red and black / blue thing but I guess it is not universal.
After checking, it is 0.2MΩ for the LDR. After changing an LDR with 8-20kΩ I am still receiving low numbers from my LDR through the serial monitor. What is going wrong here?
Something you are not telling us about, probably because you don’t know.
So a 20K LDR and a 20K resistor will work.
Can you post a good photo of your wiring.