# SIK - Circuit 1C - Photoresistor - noob question

Hi guys,

I got the above circuit working fine, but I have a question about the reason for the 10k resistor connected to the photoresistor…

1. Why is it needed?
2. Why is 10k the correct number for it?

Apologies for the dumbness, I just like to try to understand what’s going on rather than just follow the bouncing ball and move on

Andrew

The LDR and the resistor form what is known as a voltage divider - the voltage at the common point (the analog input of the Arduino) is a function of the relative resistances of the two legs of the divider. One leg is fixed at 10k ohms, while the other varies according to the amount of light that falls on the LDR. So the voltage at the common point varies according to the amount of light on the LDR, and that is the voltage that the Arduino reads.

You could simply connect the other leg of the LDR to 5v, but then you would be depending on the Arduino analog input to connect the circuit through the LDR to ground. You don’t know what this resistance is so you couldn’t calculate what the resistance of the LDR was, and you can’t be sure that the internal resistance of the analog input doesn’t change as it makes a measurement. So it’s much better to provide a known resistance as that second leg of the voltage divider. A value of 10k is not critical as long as the current through the LDR does not exceed its specifications. Different values might be selected to give the most convenient voltage readings over the range of light values that the LDR will be operating under.

3 Likes

Brilliant, thanks @Jeff105671 - nice answer.

I’ll monitor the serial port output and go through some desk calculations and make sure I understand.

Thanks for putting me on the right track - appreciate it.

Hi Jeff
I actually approximately measured this a fair while ago. It is up in the terra ohm region. About 2.6TΩ Think from memory. That is why the measurement is approximate. It is HIGH. I even forget the reason I did this. Might have wanted to check the loading effect on something else.

As you can realise it won’t be much of a voltage divider resistance.

If you are interested in how I managed to measure such a high resistance drop me a message and I will do my best to describe the method I used.
Cheers Bob

1 Like

That’s what I said. There is no need to measure it as the data sheet provides that detail - it is quoted as 100Mohms.

Hi Jeff.
Where did you find that? I looked and couldn’t find any detail like that. I think from memory I asked the forum and got no reply.
Cheers Bob

It varies according to the version of the reference document. For instance, for this one it is at table 28-8 in section 28.9. Note that the load imposed by the internal capacitor charging can mean that the impedance of the analog input port can be much lower than the quoted figure in some circumstances.

It is prefereable to start a new thread for a new topic.

Hi Jeff,

There’s probably a reason why not, but could you use the internal 20k pullup of the arduino and tie the LDR to the pin and ground? Would that create the right voltage divider structure?

I’ll admit that I’ve never used it like that, but it’d be interesting if it worked.

-James

I can’t see any reason why your couldn’t, but the problem is the same. The ‘20kohm’ pullup is nominal, and could be anything from 20k to 50k (or more on some models). The way it is implemented means that it varies. Of course, a LDR is not going to be particularly precise anyway, so depending on the application the variation might not matter.

1 Like

I thought pull ups were only on digital input pins. I haven’t checked but I may be wrong. An LDR and resistor combination would surely be an analog input wouldn’t it?
Cheers Bob

Arduino analog pins are Port C, which is described at 1.1.4 in the datasheet mentioned above (and equivalent section in the other versions). “Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).”

Hi Jeff
Thanks for that. Clears that subject up. I have never had reason to delve that deeply into the inner workings of an Arduino board as unless I have reason to think otherwise I tend to believe what smarter people than me tell me about these things.
I brought the subject up because I could not recollect anyone using the “PULLUP” statement on an analog pin. Thinking about it I have used an “analog” pin as a “digital” pin when needed so now I don’t see why not have PULLUP available.
Having said that would it not be the case that once having declared the PULLUP situation this would class the pin as “digital” and the analog (ADC) function not be available. I would have thought that in this instance using a resistor and LDR in a voltage divider configuration the ADC function would be the main objective.
Might do a bit of an experiment, if I can find the bits, for my own info.
Thanks again. Cheers Bob

1 Like

Hi Jeff, Andrew.

Regarding using “PULLUP” resistor as upper leg of voltage divider to ADC input.

I have just carried out an experiment and arrived at the following approximations.

Arduino UNO, Freetronics version, Freetronics Eleven.
DMM. UNI-T Model U771B.

Firstly, contrary to my previous thoughts you can use the “PULLUP” feature and ADC functions at the same time.

I wrote a small simple sketch to initiate the PULLUP on A0.

Measured the open circuit voltage at A0 at 4.87V.

Terminated A0 to ground with 10kΩ and measured 1.047V.

Calculated PULLUP resistance value as 36.5kΩ.

Using a second method as a check, Voltage ratio is 4.65:1.

R Pullup = (4.65 * 10) – 10 = 36.5kΩ

Open circuit = 1005.

Terminated with 10kΩ = 226.

This ratio 4.45

(4.45 * 10) – 10 = 34.5kΩ.

The small discrepancies could be caused by any number of things. DMM and resistor tolerances, slight DMM loading, Actual DC accuracy and tolerances, rounding of numbers and it goes on.

These 2 results are respectably close and I would say the value of PULLUP resistance would be ≈ 36kΩ. Now I have only checked 1 analog input and may expect some small variation but for the intended use (pullup resistors) this would not matter at all. BUT to modify this and use this as the top leg of a voltage divider I don’t think would be predictable enough and would be too high to use with anything like a LDR. This is once again an example of suggesting to use something it was not designed for.

It is my humble opinion that for the application stated at the start of this post the better way would be to forget about using PULLUP and use the lower value resistor suggested. You will then have a better chance of predicting any result.

Cheers Bob

1 Like