Stufin
Home Quick Cart Profile

PS2 Joystick Module Breakout Sensor

Buy Now on Stufin

Operating Voltage

5V or 3.3V

Operating Temperature

-20C to 85C

Storage Temperature

-40C to 125C

Package Includes

1 x PS2 Joystick Module Breakout Sensor

1 x 2x5 pin header

Documentation and Support

For detailed documentation, including datasheets, schematics, and example code, please visit the manufacturer's website or contact their technical support team.

Pin Configuration

  • PS2 Joystick Module Breakout Sensor Documentation
  • Pin Description:
  • The PS2 Joystick Module Breakout Sensor has a total of 7 pins, each serving a specific purpose. Below is a detailed description of each pin:
  • 1. VCC (Pin 1):
  • Function: Power Supply
  • Description: This pin is used to supply power to the module. Typically, a voltage of 3.3V or 5V is recommended.
  • 2. GND (Pin 2):
  • Function: Ground
  • Description: This pin is connected to the ground of the circuit, providing a return path for the power supply.
  • 3. Vout (Pin 3):
  • Function: Analog Output (X-Axis)
  • Description: This pin outputs an analog voltage signal representing the X-axis movement of the joystick.
  • 4. Vout (Pin 4):
  • Function: Analog Output (Y-Axis)
  • Description: This pin outputs an analog voltage signal representing the Y-axis movement of the joystick.
  • 5. Btn (Pin 5):
  • Function: Digital Output (Joystick Button)
  • Description: This pin outputs a digital signal indicating the state of the joystick button (pressed or released).
  • 6. CLK (Pin 6):
  • Function: Clock Signal (PS2 Communication)
  • Description: This pin is used for communication with the PS2 controller and transmits clock pulses.
  • 7. DATA (Pin 7):
  • Function: Data Signal (PS2 Communication)
  • Description: This pin is used for communication with the PS2 controller and transmits data packets.
  • Connection Structure:
  • To connect the PS2 Joystick Module Breakout Sensor to a microcontroller or other devices, follow these steps:
  • Step 1: Power Supply
  • Connect VCC (Pin 1) to a 3.3V or 5V power supply.
  • Connect GND (Pin 2) to the ground of the circuit.
  • Step 2: Analog Outputs
  • Connect Vout (Pin 3) to an analog input pin on the microcontroller (e.g., Arduino's A0).
  • Connect Vout (Pin 4) to an analog input pin on the microcontroller (e.g., Arduino's A1).
  • Step 3: Digital Output
  • Connect Btn (Pin 5) to a digital input pin on the microcontroller (e.g., Arduino's D2).
  • Step 4: PS2 Communication (optional)
  • If you want to use the module with a PS2 controller, connect CLK (Pin 6) to the PS2 controller's clock pin.
  • Connect DATA (Pin 7) to the PS2 controller's data pin.
  • Note: Make sure to consult the datasheet of your specific microcontroller or device for the correct pin connections and voltage levels.
  • By following these steps, you can successfully connect the PS2 Joystick Module Breakout Sensor to your project and start reading joystick data.

Code Examples

PS2 Joystick Module Breakout Sensor Documentation
Overview
The PS2 Joystick Module Breakout Sensor is a versatile and widely used component in IoT projects, providing a convenient interface to connect a PS2 joystick to a microcontroller or single-board computer. This module breakout sensor allows for easy connection and reading of joystick data, making it an ideal component for robotics, gaming, and interactive projects.
Pinout
The PS2 Joystick Module Breakout Sensor has the following pinout:
VCC: Power supply pin (typically 5V)
 GND: Ground pin
 CLK: Clock pin (used for serial communication)
 DATA: Data pin (used for serial communication)
 X: Analog output pin for X-axis joystick position
 Y: Analog output pin for Y-axis joystick position
 BTN: Digital output pin for joystick button press detection
Code Examples
### Example 1: Reading Joystick Data using Arduino
In this example, we will demonstrate how to read the joystick data using an Arduino board.
```c
const int xPin = A0;  // X-axis analog input pin
const int yPin = A1;  // Y-axis analog input pin
const int btnPin = 2; // Button digital input pin
void setup() {
  Serial.begin(9600);
  pinMode(btnPin, INPUT);
}
void loop() {
  int xValue = analogRead(xPin);
  int yValue = analogRead(yPin);
  int btnState = digitalRead(btnPin);
Serial.print("X: ");
  Serial.print(xValue);
  Serial.print("  Y: ");
  Serial.print(yValue);
  Serial.print("  Button: ");
  Serial.println(btnState ? "Pressed" : "Released");
delay(50);
}
```
### Example 2: Using the PS2 Joystick with Raspberry Pi (Python)
In this example, we will demonstrate how to read the joystick data using a Raspberry Pi single-board computer with Python.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
x_pin = 17  # X-axis analog input pin
y_pin = 23  # Y-axis analog input pin
btn_pin = 24  # Button digital input pin
GPIO.setup(btn_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
    x_value = GPIO.input(x_pin)
    y_value = GPIO.input(y_pin)
    btn_state = GPIO.input(btn_pin)
print("X: ", x_value)
    print("Y: ", y_value)
    print("Button: ", "Pressed" if btn_state else "Released")
    print("")
time.sleep(0.05)
```
### Example 3: Reading Joystick Data using ESP32 (MicroPython)
In this example, we will demonstrate how to read the joystick data using an ESP32 board with MicroPython.
```python
import machine
import utime
x_pin = machine.Pin(32)  # X-axis analog input pin
y_pin = machine.Pin(33)  # Y-axis analog input pin
btn_pin = machine.Pin(25, machine.Pin.IN)  # Button digital input pin
while True:
    x_value = x_pin.read_u16()
    y_value = y_pin.read_u16()
    btn_state = btn_pin.value()
print("X: ", x_value)
    print("Y: ", y_value)
    print("Button: ", "Pressed" if btn_state else "Released")
    print("")
utime.sleep_ms(50)
```
Notes
In the above examples, the analog input pins (X and Y) are assumed to be connected to analog-to-digital converter (ADC) capable pins on the microcontroller or single-board computer.
 The button pin is assumed to be connected to a digital input pin on the microcontroller or single-board computer.
 The clock and data pins are not used in these examples, as they are typically used for serial communication with the PS2 joystick controller.
 The pin connections and code may vary depending on the specific microcontroller or single-board computer being used.