button-input, staying high ??

Hi,

I have a setup with 12 buttons. 10 of them connected to the arduino pins 0, 1, 6, 7, 8, 9 and analog 0, 1, 2, and 3 (these are all configured with pinMode as inputs in the setup-part of the sketch). button 11 and 12 are connected to an I/O expander (mcp23016) which I read from through the i2c bus on analog pin 4 and 5.

Each button is connected as this:
side 1: directly to 5v
side 2: to GND through a 10k resistor AND also to an input-pin (one pin for each button)

The first issue I had was with pin 0 (the RX pin). It was acting as though it wasn't connected, although it was indeed connected. So I ended up replacing its 10kohm resistor (to GND) with a 220ohm, and then it worked fine.

I don't know why this specific pin would need a smaller resistor in order to get connection, but everything seemed to work fine now.

When I had put all my components inside my casing, suddenly the same issue started happening with other buttons as well.

So my question to you is:
what possible reasons could there be for this issue?
Is it my 10k resistors that are too much resistance, thus leaving the input pins as not-connected?
And if so; how can I measure impedance of my buttons, wires etc, and how would I find out which resistor would work?
Is this a plausible reason or is it more likely that it's a soldering somewhere?
I'm using screw connectors which are screw very tide together - but could this have anything to say?

I must admit I'm quite stranded on this one.

When I measure with my multimeter on the input pin that stays high, it gives me just below 5v reading.
I tried momentarily connecting the faulty input pin directly to GND (without any effect) and also tried connecting it to GND through a 1k and a 220ohm.. no luck.
So my best guess would be that there's a broke connection somewhere, but I really have a hard time finding it. All looks fine.

Any advise is very much appreciated.
Thanks

Søren

Pin 0 is likely to give you problems because it is held high by the USB chip (it is one of the serial ports). Putting a much lower value resistor on it would override the pull-up on it from the USB chip.

As for why it is failing now, that's hard to say.

What is your code? Do you have pull-ups enabled in software?

More info on switches: http://www.gammon.com.au/switches

Copy your sketch and show us.

side 1: directly to 5v

do not do this on digital pins 0 & 1 they are connected to rx/tx and can be damaged if +5 is connected to them.

what possible reasons could there be for this issue?

Having the thing wired up wrong, like not connecting the ground on the other side of the pull down resistors.

When I measure with my multimeter on the input pin that stays high, it gives me just below 5v reading.

Yes sounds like bad wiring.

Yeah, I found out.

My problem is now occurring on analog pin 3. Does this pin have a pull up as well? I can't seem to find it on the board schematic.

I don't have pull-ups enabled in my code. All I did was to use pinMode and set the pins as inputs - later on making a digitalRead on each of them in the loop.

LarryD:
Copy your sketch and show us.

side 1: directly to 5v

do not do this on digital pins 0 & 1 they are connected to rx/tx and can be damaged if +5 is connected to them.

But I used pinMode and set both 0 and 1 as inputs. And I haven't enabled serial commuication, and I'm using a battery for power.
So how else would I be able to use pin 0 and 1 as inputs if I can't do like this: http://arduino.cc/en/Tutorial/ButtonStateChange (connecting a button like I mentioned in the first post above)

Grumpy_Mike:

what possible reasons could there be for this issue?

Having the thing wired up wrong, like not connecting the ground on the other side of the pull down resistors.

When I measure with my multimeter on the input pin that stays high, it gives me just below 5v reading.

Yes sounds like bad wiring.

I'll have to keep rechecking this, but it really seems to be alright.

EDIT: I just measured my connection and it's good between GND and the 10k resistor

But I used pinMode and set both 0 and 1 as inputs. And I haven't enabled serial commuication, and I'm using a battery for power.

If you accidently have the button pushed when you upload a sketch you will permanently damage the board since the bootloader is in control of these pins.
I recommend you have a series resistor with the +5Volts.

and here's the code:
http://sorenandreasen.com/406-2/?preview=true&preview_id=406&preview_nonce=6f4c02efef
it was too long to write here, so it's a link to my website instead where I put it.

it's basically just some SD initialization, i2c communication (setting up the i/o expander), setting up 10 of the arduino pins as inputs and the listening for HIGH's in the loop.
When a HIGH is measured, a sample is started and a lamp is turned on (lamp outputs are on the i/o expander).

LarryD:

But I used pinMode and set both 0 and 1 as inputs. And I haven't enabled serial commuication, and I'm using a battery for power.

If you accidently have the button pushed when you upload a sketch you will permanently damage the board since the bootloader is in control of these pins.
I recommend you have a series resistor with the +5Volts.

I disconnect pin 0 and 1 each time i upload

My problem is now occurring on analog pin 3. Does this pin have a pull up as well? I can't seem to find it on the board schematic.

A4 and A5 are used by I2C. A3 should be OK.

But I used pinMode and set both 0 and 1 as inputs. And I haven't enabled serial commuication, and I'm using a battery for power.

The USB chip doesn't know whether or not you have enabled serial. Take a look at the connections between it and the main chip on the schematic.

If you are using battery power you may want to get a "raw" chip rather than a Uno (not that you have said what board you are using, as far as I can see).

soeren:
and here's the code:
http://sorenandreasen.com/406-2/?preview=true&preview_id=406&preview_nonce=6f4c02efef
it was too long to write here, so it's a link to my website instead where I put it.

Ah, no:

You do not have permission to preview drafts.

You can add attachments to your posts here.

How to use this forum

I tried taking everything apart, leaving me with ONLY the arduino uno r3 board and a push-button connected to analog pin 3 with 5v on one side and a 10k pull-down on the other side (along with a connection to analog pin 3).

This is my sketch:

void setup()

{
  Serial.begin(9600);
  pinMode(17, INPUT);
  
}

void loop()
{
  
  if(digitalRead(17) == HIGH)
  {
    
    Serial.println("17");
    
  }
  delay(300);
}

Very simple.
My connection is working (I checked it with other inputs on the board).

But when I use analog pin 3, it keeps giving me a result of HIGH.

OK so I realized there must be something completely wrong.
Perhaps I've managed to destroy analog pin 3 somehow? Is there a way to check this besides what I did now?

Auch..

If it were me I would have connected the switches between input and ground and then enabled the internal pull up resistors. Then there is little else in the wiring to go wrong. See this:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Are you sure the buttons are connected correctly, I always wire up opposite corners to ensure you get the right two pins.

That code is right for testing.

Grumpy_Mike:
If it were me I would have connected the switches between input and ground and then enabled the internal pull up resistors. Then there is little else in the wiring to go wrong. See this:-
Inputs

Are you sure the buttons are connected correctly, I always wire up opposite corners to ensure you get the right two pins.

That code is right for testing.

I'm absolutely sure I'm doing it right, because it's working with any other input on the board.
Don't you think the pin has taken damage somehow since this is happening?

My switches are this type: http://www.arcadeshop.de/Parts-Button-Switch-0250-Cherry_1079.html
I click to make connection.

OK, something interesting just showed up:
I tried putting a 1mega ohm resistor (instead of the 10k) and when measuring it with a multimeter, it showed only very little resistance.. like a few ohms.
Then I changed the input-wire to analog pin 2 (instead of analog pin 3), and now my multimeter showed 1 mega ohms resistance on the resistor.
???? What could this mean?

EDIT:
I don't get it... something is completely messed up. I hooked everything up again and hooked up analog pin 3 directly between pin and GND, and activated its pull-up plus made the necessary changes for the code to work.
And it worked!
But now suddenly my pin 1 is puking again.. it keeps being HIGH... oh my god... And my multimeter tells me all connections are fine. I've no idea why it insists on having at least one pin that won't work out.

I tried putting a 1mega ohm resistor (instead of the 10k) and when measuring it with a multimeter, it showed only very little resistance.

You should not measure resistance with a meter on a circuit that is powered. If the circuit is unpowered but wired up the resistance reading is quite meaningless as you don't know the current path. It is likely that you are just measuring the forward resistance of the protection diodes.

But now suddenly my pin 1 is puking again.

Pin 1 and 0 are both connected to the serial port and so are being pulled up by external hardware. The rules then change, you are better off using the button to ground for these.