Skip to content

Joystick Wireling Python Tutorial

TinyCircuits Joystick Wireling product photo

This Wireling features a 4 position digital joystick. This board is great for user input for games or RC (Radio Controller) projects.


Technical Details

This Wireling lets you use a discrete joystick for inputs to your development system of choice! This Up, Down, Left, Right joystick outputs data to an SX1505 I2C I/O expander.

Technical Details

SX1505 Specs

  • 8 Channel GPIO with NINT and NRESET
  • Fully programmable logic functions (PLD)

SKRHABE010 Joystick Specs

  • 4 Directional Digital Joystick
  • Center Pushbutton Input
  • I2C Semtech SX1505 I/O Expander

    TinyDuino Power Requirements

    • Voltage: 3.0V - 5.5V 
    • Current: 1.0uA (Normal Mode).  Due to the low current, this board can be run using the TinyDuino coin cell option

    Pins Used 

    • A5/SCL - I²C Clock 
    • A4/SDA - I²C Data

    Dimensions

    • 17mm x 10mm (.670 inches x .394 inches)
    • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 16mm (0.63 inches)
    • Weight: 1 gram (.04 ounces)

    Notes

    • Please note that this is not a full range analog joystick. It is essentially 4 buttons mounted sideways at the base of the joystick knob.

    Materials

    Hardware

    Required Software


    Hardware Assembly

    Plug your Wireling into the port you plan on using! The default in the included program is port 0.

    If you want to use a different port, you just need to change the port value in the program mentioned later.


    Programming

    Install the necessary Python package:

    pip3 install tinycircuits-sx1505
    

    Then you can download (above under Software) the Joystick Wireling example:

    joystick-example.py
    # Joystick Wireling Example
    # This example will print out the direction the Joystick is toggled
    # Note: The "up" direction is the one closest to the 5-pin connector
    # Written by: Laverena Wienclaw for TinyCircuits
    
    import tinycircuits_sx1505
    import tinycircuits_wireling
    import time
    
    wireling = tinycircuits_wireling.Wireling()
    wireling.selectPort(0)
    
    joystick = tinycircuits_sx1505.SX1505()
    
    while True:
        joystick.getJoystickPos()
        if(joystick.up):
            print("up")
        elif(joystick.down):
            print("down")
        elif(joystick.left):
            print("left")
        elif(joystick.right):
            print("right")
        time.sleep(.1)
    
    

    Run Program

    Navigate in the terminal to the directory with the file parent to the examples folder.

    python3 joystick-example.py
    

    Once the program is running, you should see printed output pertaining to the direction the joystick is being toggled. The joystick has four directions (up, down, left, right). Note that the "up" direction is the one closest to the 5-pin Wireling cable connector.


    Downloads


    Contact Us

    If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

    Thanks for making with us!