Stufin
Home Quick Cart Profile

Arcade 2Pin Joystick switchable to 4/8 Ways

Buy Now on Stufin

Component Name

Arcade 2Pin Joystick switchable to 4/8 Ways

Description

The Arcade 2Pin Joystick switchable to 4/8 Ways is a versatile and durable joystick module designed for various IoT applications, including gaming, robotics, and interactive systems. This component combines the classic feel of an arcade joystick with modern flexibility, allowing users to switch between 2-pin, 4-way, and 8-way configurations.

Functionality

The Arcade 2Pin Joystick module serves as an input device, detecting the direction of the joystick movement and sending corresponding signals to a microcontroller or other compatible devices. The joystick's movement is converted into digital signals, which are then transmitted through the module's output pins.

Key Features

  • Switchable Modes:
  • Arcade-style Joystick: The module features a classic, rugged arcade-style joystick, providing a familiar and intuitive user experience.
  • Durable Construction: The joystick module is built with high-quality materials, ensuring reliability and durability in demanding applications.
  • Easy Integration: The module is designed for easy integration with popular microcontrollers, such as Arduino, Raspberry Pi, and ESP32, making it an excellent choice for IoT projects.
  • Adjustable Tension: The joystick's tension can be adjusted to accommodate different user preferences, providing a more comfortable and responsive experience.
  • Debouncing Mechanism: The module features a built-in debouncing mechanism to reduce unwanted switch bounces, ensuring accurate and reliable output signals.
  • Compact Design: The module's compact size (approximately 35mm x 35mm) makes it ideal for space-constrained projects and applications.
  • 2-pin modeProvides a simple, binary output (e.g., up/down or left/right) through two output pins.
    4-way modeOutputs digital signals for four directions (up, down, left, and right) through four output pins.
    8-way modeOffers a more granular control, outputting digital signals for eight directions (up, down, left, right, and four diagonals) through eight output pins.

Operating Voltage

3.3V to 5V

Output Type

Digital

Output Pins

2, 4, or 8 (depending on the selected mode)

Joystick Travel

10mm

Operating Temperature

-20C to 70C

Storage Temperature

-40C to 85C

Dimensions

35mm x 35mm x 20mm (approximate)

Applications

The Arcade 2Pin Joystick switchable to 4/8 Ways is suitable for a wide range of IoT applications, including

Gaming consoles and controllers

Robotics and automation systems

Interactive kiosks and displays

Home automation systems

Prototyping and development projects

By combining versatility, durability, and ease of use, the Arcade 2Pin Joystick switchable to 4/8 Ways module is an excellent choice for IoT projects that require intuitive user input and reliable performance.

Pin Configuration

  • Arcade 2Pin Joystick switchable to 4/8 Ways
  • The Arcade 2Pin Joystick is a versatile component designed for use in various IoT projects, including gaming, robotics, and interactive systems. This documentation provides a detailed explanation of the joystick's pins and how to connect them.
  • Pinout:
  • The Arcade 2Pin Joystick has a total of 9 pins, which are labeled as follows:
  • GND (Ground)
  • Pin 1: GND
  • Function: Provides a ground connection for the joystick
  • Connection: Connect to the negative terminal of the power supply or the ground pin of the microcontroller/board
  • VCC (Power)
  • Pin 2: VCC
  • Function: Powers the joystick module
  • Connection: Connect to the positive terminal of the power supply (e.g., 5V or 3.3V)
  • X-Axis
  • Pin 3: X-
  • Function: Outputs the X-axis position signal (analog)
  • Connection: Connect to an analog input pin on the microcontroller/board (e.g., A0 on Arduino)
  • Pin 4: X+
  • Function: Outputs the X-axis position signal (analog)
  • Connection: Connect to an analog input pin on the microcontroller/board (e.g., A1 on Arduino)
  • Y-Axis
  • Pin 5: Y-
  • Function: Outputs the Y-axis position signal (analog)
  • Connection: Connect to an analog input pin on the microcontroller/board (e.g., A2 on Arduino)
  • Pin 6: Y+
  • Function: Outputs the Y-axis position signal (analog)
  • Connection: Connect to an analog input pin on the microcontroller/board (e.g., A3 on Arduino)
  • Switch Outputs
  • Pin 7: SW1 (UP)
  • Function: Outputs a digital signal when the joystick is moved up
  • Connection: Connect to a digital input pin on the microcontroller/board (e.g., D2 on Arduino)
  • Pin 8: SW2 (DOWN)
  • Function: Outputs a digital signal when the joystick is moved down
  • Connection: Connect to a digital input pin on the microcontroller/board (e.g., D3 on Arduino)
  • Pin 9: SW3 (SELECT)
  • Function: Outputs a digital signal when the joystick button is pressed
  • Connection: Connect to a digital input pin on the microcontroller/board (e.g., D4 on Arduino)
  • Connecting the Joystick to a Microcontroller/Board:
  • 1. Connect the GND pin (1) to the negative terminal of the power supply or the ground pin of the microcontroller/board.
  • 2. Connect the VCC pin (2) to the positive terminal of the power supply (e.g., 5V or 3.3V).
  • 3. Connect the X- pin (3) and X+ pin (4) to two separate analog input pins on the microcontroller/board (e.g., A0 and A1 on Arduino).
  • 4. Connect the Y- pin (5) and Y+ pin (6) to two separate analog input pins on the microcontroller/board (e.g., A2 and A3 on Arduino).
  • 5. Connect the SW1 (UP) pin (7) to a digital input pin on the microcontroller/board (e.g., D2 on Arduino).
  • 6. Connect the SW2 (DOWN) pin (8) to a digital input pin on the microcontroller/board (e.g., D3 on Arduino).
  • 7. Connect the SW3 (SELECT) pin (9) to a digital input pin on the microcontroller/board (e.g., D4 on Arduino).
  • Switchable to 4/8 Ways:
  • The joystick can be configured to output 4-way or 8-way signals by using external resistors and adjusting the joystick's internal settings. Refer to the joystick's datasheet or manufacturer's instructions for specific details on how to configure the joystick for 4-way or 8-way operation.
  • Remember to consult the joystick's datasheet and the microcontroller/board's documentation for specific pinout and connection details.

Code Examples

Arcade 2Pin Joystick switchable to 4/8 Ways
Overview
The Arcade 2Pin Joystick switchable to 4/8 Ways is a versatile joystick component designed for use in various IoT applications, particularly in gaming, robotics, and interactive prototypes. This joystick features a 2-pin configuration that can be switched to 4-way or 8-way modes, offering flexibility and precision in directional input.
Pinout
The joystick has a total of 5 pins:
VCC: Power supply pin (3.3V or 5V)
 GND: Ground pin
 X: Analog output pin for horizontal direction (0-1023)
 Y: Analog output pin for vertical direction (0-1023)
 SW: Digital output pin for push-button switch (HIGH/LOW)
Modes
The joystick can operate in three modes:
2-way mode: Up and Down (or Left and Right)
 4-way mode: Up, Down, Left, and Right
 8-way mode: Up, Down, Left, Right, and four diagonal directions
Code Examples
### Example 1: Basic Joystick Reading in Arduino
This example demonstrates how to read the joystick's analog output in Arduino:
```c
const int xPin = A0;  // connect joystick X output to analog pin A0
const int yPin = A1;  // connect joystick Y output to analog pin A1
void setup() {
  Serial.begin(9600);
}
void loop() {
  int xValue = analogRead(xPin);
  int yValue = analogRead(yPin);
Serial.print("X: ");
  Serial.print(xValue);
  Serial.print(" | Y: ");
  Serial.println(yValue);
delay(50);
}
```
In this example, the joystick's X and Y outputs are connected to analog pins A0 and A1, respectively. The `analogRead()` function is used to read the analog values, which are then printed to the serial console.
### Example 2: 4-Way Mode with Debouncing in Raspberry Pi (Python)
This example demonstrates how to use the joystick in 4-way mode with debouncing in Raspberry Pi using Python:
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
joystick_x = 17  # connect joystick X output to GPIO 17
joystick_y = 23  # connect joystick Y output to GPIO 23
button_pin = 24  # connect joystick push-button switch to GPIO 24
GPIO.setup(joystick_x, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(joystick_y, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(button_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def debounce(pin):
    count = 0
    while count < 5:
        if GPIO.input(pin) == GPIO.LOW:
            count += 1
        else:
            count = 0
        time.sleep(0.01)
    return True
while True:
    x_value = GPIO.input(joystick_x)
    y_value = GPIO.input(joystick_y)
    button_state = GPIO.input(button_pin)
if x_value == GPIO.LOW and debounce(joystick_x):
        print("Left")
    elif x_value == GPIO.HIGH and debounce(joystick_x):
        print("Right")
if y_value == GPIO.LOW and debounce(joystick_y):
        print("Up")
    elif y_value == GPIO.HIGH and debounce(joystick_y):
        print("Down")
if button_state == GPIO.LOW and debounce(button_pin):
        print("Button pressed")
time.sleep(0.05)
```
In this example, the joystick's X and Y outputs are connected to GPIO pins 17 and 23, respectively, and the push-button switch is connected to GPIO pin 24. The code uses debouncing to ensure accurate readings and prints the direction or button state to the console.
Note: The debouncing function is a simple example and may need to be adjusted based on the specific requirements of your project.
These examples demonstrate the basic usage of the Arcade 2Pin Joystick switchable to 4/8 Ways in different contexts. By modifying the code to suit your specific needs, you can unlock the full potential of this versatile joystick component in your IoT projects.