const int joystick_x_pin = A0;
const int joystick_y_pin = A3;
void setup() {
Serial.begin(115200);
}
void loop() {
int x_adc_val, y_adc_val;
float x_volt, y_volt;
x_adc_val = analogRead(joystick_x_pin);
y_adc_val = analogRead(joystick_y_pin);
x_volt = ( ( x_adc_val * 3.3 ) / 4095 );
y_volt = ( ( y_adc_val * 3.3 ) / 4095 );
if(x_volt > 3){
Serial.println("l");
}
if(x_volt < 1){
Serial.println("r");
}
if(y_volt > 3){
Serial.println("u");
}
if(y_volt < 1){
Serial.println("d");
}
delay(100);
}