Codey OnlineArduino- & ESP32-Komponentenbibliothek › Joystick module
Joystick module
Eingabe & Taster

Joystick module

Dieses Joystick-Modul liefert zwei analoge Positionsausgänge für die X- und Y-Achse sowie einen digitalen Drucktaster an SW. Es wird typischerweise an Versorgung und Masse angeschlossen; VRX und VRY werden über analoge Eingänge ausgelesen und SW über einen digitalen Eingang.

Breite: 41.2 mm

Pinbelegung — Joystick module

Pin Signal Beschreibung
GND ground Ground reference for the joystick module and pushbutton circuit
VCC power Power supply input for the joystick potentiometers, typically 5V or 3.3V
VRX analog Analog X-axis output from the joystick potentiometer
VRY analog Analog Y-axis output from the joystick potentiometer
SW digital Digital pushbutton output from pressing the joystick, commonly active-low

Beispielschaltplan — Joystick module

Von Nach Kabel
board:GND x1:GND black
board:5V x1:VCC red
board:A0 x1:VRX green
board:A1 x1:VRY blue
board:D2 x1:SW yellow

Arduino-Beispielcode — Joystick module

Dieses Beispiel wurde für das arduino-uno geschrieben und kompiliergeprüft. Codey Online passt es für jedes andere unterstützte Board an.

// Joystick module example for Arduino Uno
// Reads X/Y analog positions and the built-in pushbutton switch.

const int PIN_VRX = A0;
const int PIN_VRY = A1;
const int PIN_SW  = 2;

void setup() {
  pinMode(PIN_SW, INPUT_PULLUP); // SW is commonly active-low
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("Joystick module demo started");
  Serial.println("Format: X=<0-1023> Y=<0-1023> SW=<PRESSED/RELEASED>");
}

void loop() {
  int xValue = analogRead(PIN_VRX);
  int yValue = analogRead(PIN_VRY);
  bool pressed = (digitalRead(PIN_SW) == LOW);

  Serial.print("X=");
  Serial.print(xValue);
  Serial.print("  Y=");
  Serial.print(yValue);
  Serial.print("  SW=");
  Serial.println(pressed ? "PRESSED" : "RELEASED");

  delay(200);
}

Ähnliche Komponenten

12V DC power supply

12V DC power supply

5V DC

5V DC

Drukknop

Drukknop

HX711 Load Cell Amplifier

HX711 Load Cell Amplifier

Bau dein Arduino- oder ESP32-Projekt mit AI

Beschreib einfach, was du bauen willst. Codey Online schreibt den Code, zeichnet den Schaltplan, kompiliert alles und flasht dein Board direkt aus dem Browser.

Kostenlos starten