I am currently doing a project where i use the measurements from 4 ldrs. The problem is that depending on wether I am indoors or outdoors the resistance must be different in order for the measurments to be correct. Until now I would change the resistance by hand each time but I was wondering if there was a way to do it automatically, like by using an extra ldr to measure the light from the envoronment and then adjust the resistance from the rest of the ldrs accordingly. I searched through the internet but I can't find anything similar, can anyone help me?
How on earth are you changing the resistance of an LDR "by hand"? Are you using some kind of compensation factor in your code? An external variable resistor attached to the LDR? Your idea sounds like it will work, and you have a clear idea of how it should work. What is stopping you from coding it, specifically? Have you written any code at all?
Could you use a digital pot?
I think you have misunderstoond what I said, it's probably my fault since english is not my native language. What I was talking about above was not the resistance of the ldr itself but the resistor connected to it to stabalise its measurments. Thank you for your time, anyway!
I thought of using a digital potentiometer but it requires too many places on the breadboard so I am looking for another solution. If I can't find anything though I will probably use that. Thanks!
Why not just calibrate the readings in software?
I use two digital pins and one analog pin. The LDR is connected to GND and A0. One pin powers the LDR with 1k and one with 100k. Those values seem very far apart, but the result is okay, there is no need to use values closer to each other and with those values a very large range can be measured.
I make one pin OUTPUT and HIGH and keep the other one INPUT (not LOW, not HIGH, not INPUT_PULLUP). I use a delay of about 10ms (about 10ms I think, I forgot), and then I measure A0 with analogRead().
After that I power the LDR with the other pin and other resistor and measure A0.
I tried many times to make a "smart" mathematical calculation for both values of analogRead(), but that didn't work. So now I just use the average of the two. I calculate it to 0% ... 100% as a float, where 100% is the brightest light.
With 4 LDRs, you need 4 analog inputs. The pins to power it can not be combined, or else the current can flow via the other resistors to the other LDRs. So you would need 4 resistors of 100k and 4 of 1k, 4 analog inputs and 8 digital pins.
There might be a smarter way to do that. Perhaps with diodes and only two digital pins.
You can definitely combine the power pins. Of course you still need one resistor per LDR but one pin can supply sufficient current for four of them (up to 5 mA for a 1k resistor at 5V in ridiculously bright light where the LDR has negligible resistance, times four is 20 mA).
So four analog & two digital pins is what this takes. One digital pin for each set of resistors.
I use a scheme of 5 photo diodes, 4 of the photo diodes for boom positioning and one to determine ambient light. The ambient light detector is under a shade for my application.
Wiring as you should, the LDR between an analog pin and ground, one of the "reference" pullup resistors is the built-in INPUT_PULLUP.