#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void setup() {
lcd.begin(16, 2);
lcd.print("Joystic Control");
delay(1000);
lcd.clear();
}
void loop() {
int joystic_x=analogRead(A0);
int joystic_y=analogRead(A1);
int joysticx=map(joystic_x,0,1023,1,10);
int joysticy=map(joystic_y,0,1023,1,10);
if(joysticx>5){
lcd.clear();
lcd.setCursor(7,0);
lcd.print("up");
delay(10);
}
else if(joysticx<5){
lcd.clear();
lcd.setCursor(6,1);
lcd.print("down");
delay(10);
}
else{
lcd.clear();
}
if(joysticy>5){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Left");
lcd.setCursor(0,1);
lcd.print("Left");
delay(10);
}
else if (joysticy<5){
lcd.clear();
lcd.setCursor(11,0);
lcd.print("Right");
lcd.setCursor(11,1);
lcd.print("Right");
delay(10);
}
}