Skip to main content
2 of 2
added 292 characters in body

Two buttons, one LCD

I'm trying to make a program that whenever a button is push, a different word will show on a lCD screen. However, it seems that the two buttons provide the same output ("Screen A"), it's like there is no difference between them, and I'm not sure what's the cause.

The code is very simple:

const int buttonPin1 = 13;     // the number of the pushbutton pin
const int buttonPin2 = 12;     // the number of the pushbutton pin

int buttonState = 0;   

long randNumber;

void setup() {
  

  for(int x=0; x<2; x++)
  {
    pinMode(buttonPin[x], INPUT); 
  }  

}
    void loop() {
    
      for(int x=0; x<2; x++)
      {
        buttonState = digitalRead(buttonPin[x]);
    
        if (buttonState == HIGH && buttonPin[x] == 13) {
          lcd.print("  Screen A ");
        }
        if (buttonState == HIGH && buttonPin[x] == 12) {    
          lcd.print("  Screen B ");
        }
      }
      
    }

Any help is appreciated