MCP230xx Pullup function from adafruit library

Hi, i wanna use some buttons on my expander and they didn't work
What i did is just this:

  mcp.begin();      // use default address 0

  mcp.pinMode(7, INPUT);
  mcp.pullUp(7, HIGH);  // turn on a 100K pullup internally

and connect the button like so:
ground - button pin 1
pin 7(28) from expander to the button without any resistor

Why it didn't work ? i must use a resistor too ? then why i used this pullup function ?

(deleted)

spycatcher2k:
Thats a snippet - please post the full sketch - Have you tried the included example? did the example work?

i did all like in the example, and still doesn't work, i think i have to connect a resistor in order to do it

EXAMPLE CODE:

#include <Wire.h>
#include "Adafruit_MCP23017.h"

Adafruit_MCP23017 mcp;
  
void setup() {  
  mcp.begin();      // use default address 0

  mcp.pinMode(7, INPUT);
  mcp.pullUp(7, HIGH);  // turn on a 100K pullup internally

  pinMode(13, OUTPUT);  // use the p13 LED as debugging
}

void loop() {
  // The LED will 'echo' the button
  digitalWrite(4, mcp.digitalRead(7));
}

(deleted)

?

(deleted)

(deleted)

spycatcher2k:
Change the 4 to a 13 and upload and retry.

it doesn't matter, i tried it, the problem is that it give me high when is actualy low (button not even pressed)

(deleted)

spycatcher2k:
Will read high when button NOT press & Low when pressed.

It's not a code issue if you have used the example and it did not work, it's down to your wiring.

tnx for your help so far.

i just said: i connected the button to the ground and to the pin of the expander, no external resistor, the pullup function act like a resistor right ?

(deleted)

spycatcher2k:
Yes - Please post a link to where you got the expander, and a close up, in focus picture of your wiring.

Tnx your your help :smiley: i didn't know that the button is HIGH when is NOT pressed, anyway, the problem was that the jumper was not good, it was broken/cutted in the middle (inside)