#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int upButton=7;
int downButton=6;
int rightButton=5;
int leftButton=4;
// Initialize the library with the I2C address found for your display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// Initialize the LCD and specify the dimensions
lcd.init();
lcd.backlight();
// Print a message to the LCD
lcd.setCursor(1, 0); // Set the cursor to column 0, row 0
lcd.print("Hello, World!");
lcd.setCursor(1, 1); // Move to the second row
lcd.print("PUSH A BUTTON");
delay(1000);
pinMode(upButton, INPUT);
pinMode(downButton, INPUT);
pinMode(rightButton, INPUT);
pinMode(leftButton, INPUT);
}
void loop() {
// Main loop - nothing to do here
lcd.clear();
lcd.setCursor(5, 0);
boolean u=digitalRead(upButton);
boolean d=digitalRead(downButton);
boolean r=digitalRead(rightButton);
boolean l=digitalRead(leftButton);
lcd.print(u);
lcd.print(d);
lcd.print(r);
lcd.print(l);
int x=l+10*r+100*d+1000*u;
lcd.setCursor(1, 1);
lcd.println("x=");
lcd.print(x);
delay(1000);
lcd.clear();
}