Codey OnlineArduino- & ESP32-componentenbibliotheek › Joystick module
Joystick module
Input & knoppen

Joystick module

Deze joystickmodule geeft twee analoge positietrappen voor de X- en Y-as, plus een digitale drukknop op SW. Hij wordt meestal aangesloten op voeding en massa, waarbij VRX en VRY via analoge ingangen worden uitgelezen en SW als digitale ingang.

Breedte: 41.2 mm

Pinout — Joystick module

Pin Signaal Beschrijving
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

Voorbeeld-aansluitschema — Joystick module

Van Naar Draad
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

Voorbeeld-Arduinocode — Joystick module

Dit voorbeeld is geschreven en compile-gecheckt voor de arduino-uno. Codey Online past het voor je aan naar elk ander ondersteund board.

// 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);
}

Vergelijkbare componenten

12V DC power supply

12V DC power supply

5V DC

5V DC

Drukknop

Drukknop

HX711 Load Cell Amplifier

HX711 Load Cell Amplifier

Bouw je Arduino- of ESP32-project met AI

Beschrijf wat je wilt bouwen. Codey Online schrijft de code, tekent het aansluitschema, compileert het en flasht je board rechtstreeks vanuit de browser.

Gratis starten