Hi I guess my ldr is supposed to work in higher voltages because it doesn't want to detect light it wants to detect supernovas at 5 meters away.
The highest value I've got, pointing my phone's flash right over the LDR, it's merely 40 (0-1023 range).
It doesn't detect the light of my flash at more than 15~ centimeters away, and it's not because the flash is not strong, it's because this LDR refuses to have current through it.
I have two guesses: either I'm connecting something wrong, or this LDR is supposed to work with higher voltages.
At first I tried with resistors but then I tried without them, this is how I connected it: 5V pin to a leg, the other leg to GND and A5. And the programation part is just a serial.begin, serial.read and serial.println.
It came with my Arduino Uno kit so I guess it should be able to work okay with Arduino but this is driving me crazy.
The resistor value needs to be consistent with the level of light you're trying to detect and with the resistance characteristics of the particular photocell. There a table in this link which might get you closer if your LDR is similar to that example.
That may be part of the problem or all of the problem... LDRs don't respond instantly. Plus, you are reading the analog input for one " instant" every time through the loop and you may not be reading at the same instant as the flash.
is it working at all? Can you read the difference between sunlight and darkness? ...You have to "balance" the fixed resistor value with the LDR, depending on the light level so you may need to tweak your resistor value (experimentally) to get "good readings" in the desired light range, but it still may not work with a short-duration flash.
Paul__B:
Hint: The LDR connects between an analog pin and ground. No other connections. Use pinMode of INPUT_PULLUP on that pin and then analogRead.
Wait what? Isn't it supposed to be 3 cables? 5v -> LDR -> GND and Analog In?
DVDdoug:
That may be part of the problem or all of the problem... LDRs don't respond instantly. Plus, you are reading the analog input for one " instant" every time through the loop and you may not be reading at the same instant as the flash.
is it working at all? Can you read the difference between sunlight and darkness? ...You have to "balance" the fixed resistor value with the LDR, depending on the light level so you may need to tweak your resistor value (experimentally) to get "good readings" in the desired light range, but it still may not work with a short-duration flash.
With flash I mean torch mode. Like a flashlight, not just the flash you see when doing a picture. The difference between sunlight and darkness is 1-2 points.
The difference between sunlight and darkness is 1-2 points.
OK, something is seriously wrong!
Wait what? Isn't it supposed to be 3 cables? 5v -> LDR -> GND and Analog In?
There's also supposed to be another resistor in there to make a [u]voltage divider[/u]. (You can use the internal pull-up but that may not give you the right "range" of readings depending on light-level and the particular LDR. But it should work with sunlight & darkness!)
The LDR can be on the "top" or the "bottom" of the voltage divider and if you reverse them you will simply reverse the light/dark relationship. (Except if you use the pull-up, you'll have to connect the LDR on the ground side.)
You can test the analog input (and your software) by disconnecting the LDR circuit and connecting 5V to confirm you read 1023, and then switch to ground to confirm that you read zero.
Do you have a multimeter? If so, you can check the LDR's resistance at different light levels to see if it's working at all, and double-check the value of the other resistor, as well as checking the connections and voltages.
A multimeter is essential if electronics is going to be your hobby. You don't need an expensive one, if that's an issue.