#include <LiquidCrystal_I2C.h>
#define SPEED A0
#define DIR   A1

LiquidCrystal_I2C lcd(0x27,16,2);

int speedValR = 0;
int speedValL = 0;
int dirVal = 0;
int diffVal = 0; 
void setup() {
  lcd.init();
  lcd.backlight();
}

void loop() {
  speedValR = speedValL = analogRead(SPEED);
  dirVal = analogRead(DIR);
  if(dirVal<512)
  {
      diffVal = (512-dirVal);
      speedValL -= diffVal;
  }
  if(dirVal>512)
  {
      diffVal = (dirVal - 512);
      speedValR -= diffVal;
  }
  
  lcd.setCursor(0,0);
  lcd.print("Speed right:");
  lcd.print(speedValR);
  lcd.print("    ");
  lcd.setCursor(0,1);
  lcd.print("Speed left: ");
  lcd.print(speedValL);
  lcd.print("    ");
}