Signal from one of my buttons is inverted


Arduino N00b here!

I am having an issue with the following setup:

I have connected 3 2-pin buttons to my Arduino. One pin of each button is plugged to GND, the other pin is connected to one of the digital pins (3, 4, 5). Two of the buttons (let’s called them A and B, connected to pins 4 and 5, respectively) work perfectly fine and I do get a HIGH signal whenever I push one of those. The button C plugged in pin 3 seems to be inverted: I get a HIGH signal when depressed, and a LOW signal when pressed. I have tried moving the buttons to different ports (4, 5, 6, then 5, 6, 7) but the same button C seems to always be inverted. What could be the cause of that? Faulty button? Bad cabling? Arduino problem? Code issue?

Here is the code I have used to troubleshoot my setup:

//Arduino code:
#include <Bounce.h>
#include <Servo.h>


int BUTTON_A_PORT = 5;
int BUTTON_B_PORT = 4;
int BUTTON_C_PORT = 3;

Bounce bouncerA = Bounce(BUTTON_A_PORT, 5); 
Bounce bouncerB = Bounce(BUTTON_B_PORT, 5); 
Bounce bouncerC = Bounce(BUTTON_C_PORT, 5); 


void setup(){
  // Set up 19200 for the rate of communication

  digitalWrite(BUTTON_A_PORT, HIGH);
  digitalWrite(BUTTON_B_PORT, HIGH);
  digitalWrite(BUTTON_C_PORT, HIGH);

void loop() {
  if ( == HIGH) {
    Serial.println("Button A has been pressed");
  if ( == HIGH) {
    Serial.println("Button B has been pressed");
  if ( == HIGH) {
    // If I open the Serial Monitor, this will be printed many times
    Serial.println("Button C has been pressed");

Thanks in advance for your help.

Note: Just added the bouncer, but I had the same issue without using it.

What's the circuit exactly? Are they floating when not closed?

Since you seem to have pull-ups enabled, I would expect LOW when pressed, not high.

Your troublesome button could be a push to break buttion instead of the normal push to make sort.

Thank you for your replies.

All three buttons are (seem) identical. No physical difference in shape or color as far as I can see.

The circuit looks like the "Internal pull-up resistor" in the Gammon Forum : Electronics : Microprocessors : Switches tutorial page. The three buttons all have one of their legs connected to Gnd via a relatively long wire (10~15 inches) and a 23k Ohms resistor. The other leg of the buttons is connected to pins 3, 4, 5 respectively via a wire of the same length. The two wires of each button are twisted.

Thank you for your replies.

All three buttons are (seem) identical. No physical difference in shape or color as far as I can see.

Doesn't mean a thing. Push-to-make and push-to-break switches from the same manufacturer usually look identical. Test your 'odd' switch with a meter or a simple circuit tester (battery and bulb or LED).