[Solved] Wiring a Button With N.O. and N.C.?

Hi, I'm trying to wire up a big red arcade-style button with one Normally Open and one Normally Closed terminal to my Arduino but am unable to get any correct readings. (I followed the following thread as a model: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1215022988)

I connected the NO terminal of the button to a ground pin on the Arduino, and then the NC terminal to a regular pin (9). I then enabled the (supposed) internal pull-up resistor on pin 9. Theoretically, I thought this would make it return a 0 when the button is pushed down and a 1 when not. Instead, it always returns 1, regardless of whether or not the button is pushed down.

Here's my code, if it helps:

int inputPin = 9;

int buttonState;
int val;

void setup() {
    pinMode(inputPin, INPUT);
    digitalWrite(inputPin, HIGH);
    
    Serial.begin(9600);
    buttonState = digitalRead(inputPin); // store initial button state (should be high)
}

void loop() {
    val = digitalRead(inputPin);
        
    if (val != buttonState) {
        if (val == LOW) {
            Serial.println("Button - low");
        } else {
            Serial.println("Button - high");
        }
    }
    
    buttonState = val;
}

Would anybody be able to tell me what I am doing wrong here?

Thanks in advance.

Have you verified you used the correct contacts?

You can use a multimeter to see if the node connected to pin 9 moves from 5V to 0V when the button is pressed.

If its got a NO and a NC terminal, then there must also be a COMM (common) terminal. Use COMM and one of NO or NC. Using NO and NC can't work, they never touch or move, the common moves from NC to NO when pressed.

The NC and NO buttons have no connection facility to each other. You need to use either (C and NO) or (C and NC) to create a functional circuit.

Edit : Apologies to above respondent for repeating their input - I missed reading it

Thank you all for your replies. I looked more closely at the button and did in fact find a COMM terminal that's partially hidden by the design of the button.

I adjusted my wiring appropriately and spent the vast majority of my afternoon/evening still unable to get it working. Then, about twenty minutes ago, I discovered one of the wires had come loose and popped out of my Arduino. One of those nights I guess.

I'll rekindle my efforts again in the morning, but I think for all intensive purposes this problem is solved. Thank you all again.