Analog input pull up

I've kinda got a question. I left my Arduino so I cant check it out, but I kinda try to understand how internal analog input pull up resistor gets in circuit

I understand what is pull ups and pull downs, just how should I connect LDR if I'm using internal pull up?

5V --|LDR|---A0 pin?

Thanks

the internal pullup is 50k ohms. What is your question ?

how should I connect LDR if I'm using internal pull up?

Code:

void setup ()
{
pinMode (A0, INPUT_PULLUP);
} // end of setup

5V --|LDR|---A0 pin?

Or should I just use this schematic without internal resistors? http://www.hobbytronics.co.uk/image/data/tutorial/arduino-tutorial/ldr_nightlight.jpg

KarolisL:
how should I connect LDR if I'm using internal pull up?

From the analog input (whichever it is) to ground.

Same situation if I would like to use standalone atmega328?

The pull-up is inside the chip. The Arduino is just a board with a connection from the chip to a terminal.

If you thought the LDR should be connected to 5V, you clearly did not understand what a"pull-up" is! :astonished:

Yeah, now I understand how I messed up :smiley: probably wasn't fully awake. Thanks for the help :slight_smile:

Note the internal pullup isn't actually a resistor(*), isn't linear, is only spec'd to be between
20k and 50k. If you are measuring something with an analog pin, use only an external
resistor of known value.

(*) FETs are used on chips like this to mimic resistors since they are
easy to fabricate on die. For a high resistance value the FET will have a long
narrow gate. The resistance of such a device is voltage dependent.

This is ot a good application for an internal pullup. Why did want to use it? (to save having to buy a resistot ?

MarkT:
Note the internal pullup isn't actually a resistor, isn't linear, is only spec'd to be between 20k and 50k. If you are measuring something with an analog pin, use only an external resistor of known value.

Somewhat irrelevant in this case - he's sensing an LDR which isn't that linear anyway. And I doubt the accuracy is critical but at least it should be repeatable.

Its never been a problem adding additional resistor in the circuit thx for ebay :smiley:

My eye got caught on that code fragment, I haven't seen analog input like that. So out of curiosity I just asked. Just for common knowledge :slight_smile:

Thanks for responses

raschemmel:
This is ot a good application for an internal pullup. Why did want to use it? (to save having to buy a resistot ?

So what would be good application for internal pullup?

a switch to gnd

KarolisL:
So what would be good application for internal pullup?

Most things - including an LDR. It will work fine, particularly at low light levels. You may however need an external pull-up to "calibrate" the LDR for higher light levels where its resistance is less than about 5k.

Yes, you should start a new thread, not reanimate a three-year old one.