Arduino Internal Pull-up Resistors.

Hi everyone,

I'm having a little difficulty understanding how the internal pull-up resistors work. Does this mean when they are used I don't need to you a resistor lets say between an LED and the pin? How about when using a switch ( toggle or button). Using a POT? Can you call the resistor on all the pins (3-13, analog 0-5 when used as digital)?

Also I heard that you can set different values for the internal pull-up. All the examples I've seen just set the pin to HIGH. Is there a way to define the resistors resistance? Sorry if this was asked before. I tried searching but couldn't find anything ( maybe I worded it wrong) If there is another topic, please just point me to it.

Thanks Again.

The internal pull-ups only effect the pin if it is configured as an input pin, it has no bearing on how an output pin behaves. An output pin would still require a series connected current limiting resistor to safely drive a LED. The resistor needs to be sized to limit the current to the maximum value allowed for the LED or 40ma to protect the output pin, which ever is less.

The internal pull ups can save you from needing an external pull up resistor to interface with switch contacts. The pull-up will insure that there is a consitant logic HIGH when the switch is open and will read as a LOW when the switch contacts are closed if the other end of the switch is wired to ground. There is no way to change the value of the internal pull up resistors, they are what are, fixed and of high resistance.

That all make sense?

Lefty

Lefty,

Good explanation. Can you expand on the pullup vs pulldown configuration?

I know how they work, but was wondering why a pullup is the onboard choice vs pulldown?

I tend to think of the "off" state of a switch (not pressed) as LOW and the "on" (pressed) as HIGH. When I have wired switches in circuits I've made, I use pulldowns. It also makes a software correlation between "on", TRUE, and HIGH, which is conceptually nice.

Any enlightening thoughts? Thanks.

.andy

Ah that makes sense now thanks for the explanation. When you say the resistor needs to be sized to limit current to protect the output pin, doesn't the current flow out of it? I can see protecting the LED but how ( or why ) would you go about protecting the actual output pin? Isn't the pin designed to allow maximum current to flow from it at all times? Maybe I'm reading that wrong.

One thing that i don't like about using them is the fact you call a switch HIGH when its open. Kinda thinking along the lines of what Andy is saying. It makes more sense to me to think of LOW as off and HIGH as on. But in the context of the whole pull-up resistor it makes sense to be called HIGH because your pulling the voltage up to 5v ( or what ever)

Isn't the pin designed to allow maximum current to flow from it at all times? Maybe I'm reading that wrong.

No, a digital output pin is just a voltage source, either at 0vdc or 5vdc and the amount of current drawn is determined only by the external load resistance. You can burn up a digital output very easily (and quickly) by grounding it and then setting it to a high or wiring +5vdc to the pin and setting the output low. The 40ma max current rating is just a warning specification, there is nothing inside the chip to limit it to that safe value, your circuit has to limit the current to a safe value. If you require more current then a switching transistor or relay is then called for.

As far as logic levels for inputs, a 0vdc will always read as a LOW in software and if you wish to utilize the internal pull-up resistors to make your switch simpler to connect then you have to change your thinking to a LOW means switch active and a HIGH means switch inactive, or utilize a normally closed switch contacts that open when you press it. Otherwise you will have to utilize external pull down resistors to make your switch logic match your 'normal thinking'. This was always the case with logic circuits, a designer is free to define an output as 'active' low or 'active' high to save or optimize on the components used or to be compatable to what a logic node is wiring to.

Lefty

You can burn up a digital output very easily (and quickly) by grounding it and then setting it to a high or wiring +5vdc to the pin and setting the output low

Do you have a for instance example of how one many accidentally make this mistake?

Do you have a for instance example of how one many accidentally make this mistake?

I have no idea of how many may have made that mistake, but I'm sure it has and will continue to happen in the future to someone. It could be made as a simple wiring error where the person knows better but was careless in construction. In other cases a person may come to using an Arduino with no prior experience or knowledge of electronics fundamentals and thinks he/she is doing the proper thing.

That's what makes this forum such a valuable part of the Arduino community, one can learn just by reading the posts and learn from others mistakes.

I've personally bricked one AVR chip due to a brain fart on a solderless breadboard, thought I was hooking a wire to a +5vdc buss when in fact it was my +12vdc buss, it happens sometimes :P

Lefty

Yea this place is great I've learned a bunch so far. its pretty overwhelming at first I feel like no matter where I choose to start learning, there is another core concept they refer to and I have to go learn that which brings up another concept to learn and the cycle continues haha. Oh well ..

another concept to learn and the cycle continues haha. Oh well ..

I can understand that. An Arduino looks so all cute, simple and inexpensive that some can be surprised to find out that it is built on top of a full blown high level software language and wiring it to anything external requires one to understand and obey all the laws and rules of electronic fundamentals.

Good luck in your Arduino endeavors ;)

Lefty