internal pulldown resistors?

Hi all, I have read in the reference that the arduino has internal pullup resistors and you can set them by doing the following

pinMode(pin, INPUT); // set pin to input digitalWrite(pin, HIGH); // turn on pullup resistors

can you do this to get pulldown resistors?

pinMode(pin, INPUT); // set pin to input digitalWrite(pin, LOW); // does this make it a pull down?

also can i do it in conjunction with an interrupt?

such as the following...

pinMode(2, INPUT); digitalWrite(2, LOW); attachInterrupt(0, increment_counter, RISING); // interrupt 0 is digital pin 2

will the above work or do i have to do the following?

pinMode(2, INPUT); digitalWrite(2, HIGH); attachInterrupt(0, increment_counter, FALLING); // interrupt 0 is digital pin 2

if the change to above code is not obvious, what i did was switch it to a pull up and change the interrupt to test for FALLING instead of RISING.

I am trying to detect a reed switch pulse with an interrupt.

thanks

Jeff O'Brien

look at the Atmega datasheet on page 72- only pull-up resistors are available, no pull-downs.

D

If you are hooking up a switch of some kind, you can eaily make use of the internal pull up resistor. Usually we use a switch to turn on the electricity. You push the button and the line goes high. and you would need a pull down resistor to tie the input low. But we also make the electricity go the other way. You use the pull up resistor to tie the input high. You hook one end of the switch to the input and the other end to ground, then when you push the switch the input goes low. Then in your software you look for the input to go low when the button is pushed versus high.

great thanks
this is what i am doing now
thanks again
Jeff

This works great. In the Arduino examples they always seem to use an external resistor, any idea why?

no clue

the Arduino examples they always seem to use an external resistor

1) "internal pullups" are sort of mysterious. ("I Write to the pin even though its set to be an input?") 2) a external pullup/down configuration it portable to other cpus and/or situations where an internal pullup may not be available. (for example, if you MUST use a pulldown for some reason, you've just discovered that there is no internal pulldown.)

they always seem to use an external resistor, any idea why?

The other thing is that the internal pull up resistors are only weak, about 30K, some applications require a stronger pull up to give more noise margin.

1 Like

Thanks!

Oh it’s a pity atmega s don’t have pull-down resistors. Anyone aware of a chip which has them?

pull ups are more commonly used

Anyone aware of a chip which has them?

No micro controller I know has them. The only place I have seen them is in large FPGAs.

Pull up resistors are the more common because that is what you need 99.99% of the time due to the nature of TTL inputs (and logic inputs in general). The ATMEGA is some what of an exception:- 1) In having an input structure that will work with reasonably high values of pull downs. 2) In having a large number of naive users that think pull downs are more logical.