How fragile are LDR sensors - and could mine be broken?

“ Analog pins do not have an internal pull up.”

News to us :wink:

larryd:
“ Analog pins do not have an internal pull up.”

News to us :wink:

Who would us be? News to me if I can use a pull up on an analog input pin. What exactly would the pin pull up to? Every reference I have seen makes use of mode: INPUT, OUTPUT, or INPUT_PULLUP is to a digital pin. Now show me a reference to an analog input pin being used with INPUT_PULLUP and I'll admit my ignorance.

Ron

For example, on an UNO, A0 can also be used as a digital pin i.e. D14.

“Us” people who haunt this site.

Did you ever measure the light and dark actual resistances? Attached is an example of a LDR used as part of a voltage divider network. Note how the Vout increases or decreases based on the configuration.

You don't just choose a series resistor based on a diagram seen somewhere. There are actually formulas used for this and a big part depends on the LDR chosen and why knowing light and dark resistance is important. With light and dark resistances known we can choose a series resistor and know pretty accurately what the output to a uC will be. That is how it is done.

Give this a read and try to understand what is happening.

https://www.petervis.com/electronics%20guides/calculators/LDR/LDR.html

Ron

LDR.png

larryd:
For example, on an UNO, A0 can also be used as a digital pin i.e. D14.

“Us” people who haunt this site.

Ah, I confess as to my bad. Yes, I was aware any analog input pin could be used as a digital input pin. What I was missing is that yes, the analog input pins can be used with a pull up. I was wrong on that. All you needed to do was point me here:

https://www.arduino.cc/en/Tutorial/AnalogInputPins

The reason I oppose doing this with an LDR is with only the LDR and relying on an internal pullup you really don't know what you have as to internal pullup resistance and verse LDR light and dark resistance. That is not an excuse as I already confessed my being wrong. :slight_smile:

Thanks
Ron

Ron_Blain:
Ah, I confess as to my bad. Yes, I was aware any analog input pin could be used as a digital input pin.

Well, close.

On an ATmega328P processor (as used in the Uno, Nano, Pro Mini) A0-A5 are basically digital pins with analog input ability. A6 and A7 however (not available on the Uno) are the odd ones out as those two are analog input only, and I don't know whether they have an internal pull-up. Probably not.

I don't know of any other ATmega processors that have those analog-only inputs.

Also I see those pins as digital pins first, analog inputs second. This as there's only one ADC which is shared between all of them.

All this information can be found in the data sheet of the respective processors.