Internal pullups not working?

Relative newbie here. I spent the last few month writing a sketch for contolling a stepper motor. When trying out the latest version of my sketch, which involved several push buttons and the bounce2 library, none of the buttons were working.

Long story short, for troubleshooting, I ended up stripping down everything to the bare minimum (just one button) and went through some simple example sketches: button sketch with external pull-up (worked fine), debounce sketch with external pull up (worked fine, too) and finally the internal pull-up sketch and that didn't work (wiring for that one is pretty simple, so I'm fairly sure that's not the culprit).

Now, I'm wondering: are there any more troubleshooting options? More ways to test those internal pullups or should I consider them fried? Do I get a new Arduino (Uno) board at this point or just the Atmega chip?

Thx

To check the internal pull ups, you can enable them, and then test from the current from the pin to ground with an ammeter/multimeter. You should have 5v over 20K ohms.

The wiring of some 4 leg buttons can be confusing because two of the four legs are always connected to each other . If you can confirm the operational behavior or your button with a multimeter it would be best. I think that if you wire diagonally across the button then it will always be open when not pressed, and it will close the circuit when pressed.

Wiring should be from the input pullup pin, across the switch to ground.

Also, the logic is inverted with Input Pullup, and the pin will read low when the button is pressed, and high when it is open.

What board and IDE do you have. I believe that before the current generation you used

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

instead of pinMode (pin, INPUT_PULLUP)

Thanks for the reply. I already checked the buttons with a multimeter and they behave as expected (i.e. I didn't put them in 90deg rotated). I'm also aware of the reversed high/low logic when using pull-ups and my sketch and the pull-up example sketch take that into account. The IDE is 1.0.5r2 and my board is an Uno R3, which should support the INPUT_PULLUP logic.
Will try to measure the output of the button pin later.

pipetman:
finally the internal pull-up sketch and that didn't work

A clear picture of your wiring would be helpful. Maybe also a schematic (hand drawn okay).

Also, sometimes nice to see the code to make sure you aren't inadvertently turning the resistor off somewhere (see below for test.)

pipetman:
(wiring for that one is pretty simple, so I'm fairly sure that's not the culprit).

You'd be surprised. New users always want to blame the hardware... :wink:

pipetman:
Now, I'm wondering: are there any more troubleshooting options?

Use a simple sketch to turn on the pull-up and measure the pin with a mulitmeter.

void setup() {
   pinMode(2, INPUT_PULLUP);
}

void loop() {}

Use your multimeter to test the voltage of the pin with the pull-up on. Disconnect your button or any other hardware. Although, you might need to add a piece of wire or trace back to the pin on the ATmega328. I wouldn't trust just "sticking your probe" into the pin header of the Arduino.

If you measure 5V (or whatever you 5V pin is at), the pull-up is working fine.

A clear picture of your wiring would be helpful. Maybe also a schematic (hand drawn okay).

I simply used the wiring scheme and the code from the Arduino tutorial page: http://arduino.cc/en/Tutorial/InputPullupSerial
One leg of the button connected to ground, the other to pin2.

You'd be surprised. New users always want to blame the hardware...

That's how I felt when I wrote the post, but I was/am somewhat stumped at this point.

Use a simple sketch to turn on the pull-up and measure the pin with a mulitmeter.

So, I manged to run that sketch and simply measured the wires coming from ground and pin2 (didn't get around to do much else). The reading was 4.3 V. Maybe a bit on the low side, but showing that the pin is doing the right thing!??! I noticed, however, that even when the upload of that short sketch of yours was finished, the TX LED would sometime flicker or stay on. Same thing with the 'pullup' sketch from the tutorial mentioned above...

pipetman:
The reading was 4.3 V. Maybe a bit on the low side,

A pin with the pull-up enabled (and nothing else connected) will measure the same as the 5V pin. So compare to that.

pipetman:
the TX LED would sometime flicker or stay on

What do you mean stay on? For how long? TX should only be on while you are actually transmitting. The really simple code example I gave you, does nothing with the serial port, so after the code has been uploaded, it shouldn't be on anymore.

Are you sure the IDE isn't giving you an error message after it is done uploading? Copy the text in the black area and paste it here, after you upload the simple example I gave you.

A pin with the pull-up enabled (and nothing else connected) will measure the same as the 5V pin. So compare to that.

Hmm, the 5V rail measured against ground reads 4.6 V. In the same ball park, but not spot on (the UNO is powered through the USB port of an ancient netbook).

What do you mean stay on? For how long? TX should only be on while you are actually transmitting.

TX shouldn't be on continuously, but it is. Between reboots of the Arduino (power cycling, not resetting), that behavior can change and sometimes it's LED13 that stays on permanently (although not prompted to do so by any code)

Are you sure the IDE isn't giving you an error message after it is done uploading? Copy the text in the black area and paste it here, after you upload the simple example I gave you.

The IDE comes back with: Binary sketch size: 690 bytes (of a 32,256 byte maximum)
So nothing out of the ordinary here.

I was pondering for a long time to get a second Arduino board (a Nano) to tinker with. I might as well do that and see how it works out...

pipetman:
Hmm, the 5V rail measured against ground reads 4.6 V.

That's outside of the USB spec. There's probably some ripple on that rail as well, which may be causing the erratic behavior. A good test might be putting a powered hub in between.

pipetman:
In the same ball park

That's part of the problem. It shouldn't be "in the ball park." It should be within a few millivolts, maybe 10s of millivolts.

pipetman:
TX shouldn't be on continuously, but it is. Between reboots of the Arduino (power cycling, not resetting), that behavior can change and sometimes it's LED13 that stays on permanently (although not prompted to do so by any code)

Well clearly something is broken. If you aren't sending stuff over the serial port, your TX light shouldn't be on.

Again, I think your supply voltage is doing something funky, giving you bad behavior.
I was pondering for a long time to get a second Arduino board (a Nano) to tinker with. I might as well do that and see how it works out...

Well clearly something is broken. If you aren't sending stuff over the serial port, your TX light shouldn't be on.
Again, I think your supply voltage is doing something funky, giving you bad behavior.

I'll hook it up to some external power source and see what happens.
Thanks for all your input, very instructive and very much appreciated!

Hmm, the 5V rail measured against ground reads 4.6 V. In the same ball park, but not spot on (the UNO is powered through the USB port of an ancient netbook).

I'd say the "netbook" is not up to scratch, do you have a desktop pc you can power it up with?

Tom..... :slight_smile:

I'd say the "netbook" is not up to scratch, do you have a desktop pc you can power it up with?

I hooked it up to a 12V SLA battery, but the 'internal pull-up' sketch still would not work.

I actually received my Arduino Nano board last night and with that the 'internal pull-up' sketch works fine and just as expected. So, I assume, something with that Uno must have gone wrong...