Multiple Buttons on seperate digital inputs

I cannot figure out where I’ve gone wrong. I am trying to hook up multiple buttons (each on their own pin) and read the results. The first two work fine (pins 2, and 3) but pin 4 doesn’t seems to get a response. So, I stripped down the code to this (see below) and set it to only read that one button. It works with the other buttons, just not the last one.

const int pinBtn[] = {2,3,4};
const int pinLed = 11;

int pinState = 0;


void setup(){
  pinMode(pinLed, OUTPUT);
  for(int i = 0; i<3; i++){
    pinMode(pinBtn[i], INPUT);
  }
}

void loop(){
  pinState = digitalRead(pinBtn[2]);
  if(pinState == HIGH){
    digitalWrite(pinLed, HIGH);
  }else{
    digitalWrite(pinLed, LOW);
  } 
}

If I change the pinBtn[2] index in line:   pinState = digitalRead(pinBtn[2]); to a 0 or 1 then the corresponding button does work. I have also changed the last pin (pin 4) to multiple other pins (in case that one is fried, but same result).

Breadboard View:
https://docs.google.com/document/d/15t35RBKxeM9c0rv81EGEIXQGhHtkzm5hxXorcBuejlY/edit?usp=sharing

Try rotating that button through 90 degrees.

Thanks, that wasn’t actually the problem.
Turns out that i bent one of the leads when i put it in.

:blush:

Yes but it made you find the problem. :)

postazure: void loop(){   pinState = digitalRead(pinBtn[2]);   if(pinState == HIGH){     digitalWrite(pinLed, HIGH);   }else{     digitalWrite(pinLed, LOW);   } }

Contracts to:

void loop(){
 digitalWrite(pinLed, digitalRead(pinBtn[2]));
}