5V or 3.3V
5V or 3.3V
-20C to 85C
-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.
PS2 Joystick Module Breakout Sensor DocumentationOverviewThe 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.PinoutThe 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 detectionCode Examples### Example 1: Reading Joystick Data using ArduinoIn 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 pinvoid 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 timeGPIO.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 pinGPIO.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 utimex_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 pinwhile 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)
```NotesIn 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.