KY-023 - XY-Joystick-Modul

KY 023Einführung

Es handelt sich um einem PS2 kompatibles Joystick-Modul mit 2 analogen Potentiometern (X und Y) und einem digitalen Tastschalter.

Anschluss

Achtung: Es ist zu klären, ob für den digitalen Schalter wegen der LED ein Vorwiderstand nötig ist!

ArduinoModul
GND Pin -
+5V Pin +5V
Pin A0 Pin VRx
Pin A1 Pin VRy
Pin 3 Widerstand??? –> Pin SW
 

Beispielcode

// Module KY023
// For more info see http://tkkrlab.nl/wiki/Arduino_KY-023_XY-axis_joystick_module
int JoyStick_X = A0; // x
int JoyStick_Y = A1; // y
int JoyStick_Z = 3; // key
void setup ()
{
  pinMode (JoyStick_X, INPUT);
  pinMode (JoyStick_Y, INPUT);
  pinMode (JoyStick_Z, INPUT);
  Serial.begin (9600); // 9600 bps
}
void loop ()
{
  int x, y, z;
  x = analogRead (JoyStick_X);
  y = analogRead (JoyStick_Y);
  z = digitalRead (JoyStick_Z);
  Serial.print (x, DEC);
  Serial.print (",");
  Serial.print (y, DEC);
  Serial.print (",");
  Serial.println (z, DEC);
  delay (100);
}