I'm simply trying to drive buttons off digital pins. I have the buttons wired to 3.3V through a 1k resistor and then each button leads to a different pin. I'm then trying to use the internal pulldown to pull the pin down to ground when the button is open (to avoid artifacts as described here). I'm basically doing:
Pins 4,16,17,18 work as I expect. Pins 2 and 3 do not. When I attach a meter between pin 2 and ground with the button open, I see ~ 1V. Between 4 and ground, I see low millivolts. With the buttons closed I always see 3.3 V. I've tried a number of different combinations of pins, and always see the same behavior: a few of the lower number pins don't work as expected.
My understanding is that enabling the internal pulldown should act exactly like connecting a ~20k resistor between that pin and ground. Is this correct?
I'm not at all an electronics person so it's quite possible something else is going on. I know it's not the buttons because I've tested them with a multimeter and they read no connection open and ~ 1 ohm closed.
The complete code is here (it's more complex, involving analog read on a slider pot), etc.
I'm sure this is something really stupid I'm doing. Makes me feel dumb. Any help would be most appreciated.
-c
Code:
static const uint8_t buttonPins[MAX_BUTTONS] = {2, 3, 4, 16, 17, 18};
for (int i = 0; i < MAX_BUTTONS; ++i) {
uint8_t pin = buttonPins[i];
pinMode(pin, INPUT);
*portConfigRegister(pin) = PORT_PCR_MUX(1) | PORT_PCR_PE;
attachInterrupt(pin, CHANGE);
}
Pins 4,16,17,18 work as I expect. Pins 2 and 3 do not. When I attach a meter between pin 2 and ground with the button open, I see ~ 1V. Between 4 and ground, I see low millivolts. With the buttons closed I always see 3.3 V. I've tried a number of different combinations of pins, and always see the same behavior: a few of the lower number pins don't work as expected.
My understanding is that enabling the internal pulldown should act exactly like connecting a ~20k resistor between that pin and ground. Is this correct?
I'm not at all an electronics person so it's quite possible something else is going on. I know it's not the buttons because I've tested them with a multimeter and they read no connection open and ~ 1 ohm closed.
The complete code is here (it's more complex, involving analog read on a slider pot), etc.
I'm sure this is something really stupid I'm doing. Makes me feel dumb. Any help would be most appreciated.
-c