int JOYSTICK_X = 0;
int JOYSTICK_Y = 2;
int JOYSTICK_BTN = 16;
int vrx, vry;
bool sw;
void setup() {
pinMode(JOYSTICK_X, INPUT);
pinMode(JOYSTICK_Y, INPUT);
pinMode(JOYSTICK_BTN, INPUT_PULLUP);
}
void loop() {
vrx = analogRead(JOYSTICK_X);
vry = analogRead(JOYSTICK_Y);
sw = digitalRead(JOYSTICK_BTN);
if (sw == LOW) {
printf("Fire at will!\n");
} else {
if (vrx > 1800 && vrx < 2200 && vry > 1800 && vry < 2200) {
printf("Ship reporting!\n");
}
else if (vrx < 1800 || vrx > 2200 || vry < 1800 || vry > 2200) {
printf("Engines engaged!\n");
}
}
delay(100);
}