
/*
  EasyJoystick - newUp example

  Demonstrates how to detect joystick movement using the "new" functions
  (newUp, newDown, etc.), which trigger only when the position changes.

  Prints the direction to the Serial Monitor whenever the joystick
  moves to a new position.

  Wiring:
    VRx -> A1
    VRy -> A2
    VCC -> 5V
    GND -> GND
	
  Note:
    joystick.begin(xPin, yPin, flipX, flipY)
    - xPin, yPin must be analog pins
    - flipX/flipY invert directions if needed

*/

#include <EasyJoystick.h>

EasyJoystick joystick;

void setup() {
  joystick.begin(A1, A2, true, true);
  Serial.begin(115200);
}

void loop() {
  joystick.loop();
  if (joystick.newMiddle()) {
    Serial.println("middle");
  } else if (joystick.newUp()) {
    Serial.println("up");
  } else if (joystick.newDown()) {
    Serial.println("down");
  } else if (joystick.newLeft()) {
    Serial.println("left");
  } else if (joystick.newRight()) {
    Serial.println("right");
  }
}
