Tags: Arduino, JoyStick, Breakout, Module, Shield, PS2, Joystick, Game, Controller

JoyStick Breakout Module Shield PS2 Joystick Game Controller For Arduino

  • 15.00 AED

    24.00 AED

    • Ex Tax:15.00 AED
    • Product Code: PS2 Arduino Joystick
    • Availability: In Stock
    The Model: KY-023 (or KY-23) is an easy-to-use analog joysticks for the Arduino microcontroller. The joysticks features two dimensions (x and y axis) as well as a state that is set when the joystick is pressed. log joysticks are a great way to add some control in your projects. In this tutorial we w..

    The Model: KY-023 (or KY-23) is an easy-to-use analog joysticks for the Arduino microcontroller. The joysticks features two dimensions (x and y axis) as well as a state that is set when the joystick is pressed. log joysticks are a great way to add some control in your projects. In this tutorial we will learn how to use an analog joystick module.

    CONNECTIONS

    We need 5 connections to the joystick.

    The connection are : Key, Y, X, Voltage and Ground.

    “Y and X” are Analog and “Key” is Digital. If you don’t need the switch then you can use only 4 pins.

    THE CODE

    Analog joysticks are basically potentiometers so they return analog values.

    When the joystick is in the resting position or middle, it should return a value of about 512.

    The range of values go from 0 to 1024.


    // Arduino pin numbers
    const int SW_pin = 2; // digital pin connected to switch output
    const int X_pin = 0; // analog pin connected to X output
    const int Y_pin = 1; // analog pin connected to Y output
    
    void setup() {
      pinMode(SW_pin, INPUT);
      digitalWrite(SW_pin, HIGH);
      Serial.begin(115200);
    }
    
    void loop() {
      Serial.print("Switch:  ");
      Serial.print(digitalRead(SW_pin));
      Serial.print("\n");
      Serial.print("X-axis: ");
      Serial.print(analogRead(X_pin));
      Serial.print("\n");
      Serial.print("Y-axis: ");
      Serial.println(analogRead(Y_pin));
      Serial.print("\n\n");
      delay(500);
    }
    


    TUTORIAL VIDEO
    DOWNLOAD

    Just copy and paste the above code in the Arduino IDE to program your Arduino.

    There are no reviews for this product.

    Write a review

    Please login or register to review