I am working on a project and i'm trying to get the lcd to print what button was pressed, but it does not respond to the buttons I am going off of my "Arduino Projects Book" so that may be why the code is a bit messy.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int buttonOne = 8;
const int buttonTwo = 7;
int prevSwitchState = 0;
int switchState = 0;
int prevSwitchStateTwo = 0;
int switchStateTwo = 0;
void setup(){
lcd.begin(16, 2);
pinMode(buttonOne && buttonTwo, INPUT);
lcd.print("Welcome");
lcd.setCursor(0,1);
lcd.print("Lftbtn = A");
delay (5000);
lcd.clear();//Clears screen
lcd.print("Rgtbtn = B");
delay (5000);
lcd.clear();
}
void loop(){
lcd.setCursor(0,0);
lcd.print("test");
switchState = digitalRead(buttonOne);
if (prevSwitchState != switchState){
if (buttonOne == HIGH){ lcd.print("B");
}
}
else if ( prevSwitchStateTwo != switchStateTwo){
if (buttonTwo == HIGH){
lcd.print("A");
}
}
}