Joystick Wireling Python Tutorial
This Wireling features a 4 position digital joystick. This board is great for user input for games or RC (Radio Controller) projects.
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.
- 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
- A5/SCL - I²C Clock
- A4/SDA - I²C Data
- 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)
- 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.
- Python 3 (Python 2 is not supported!)
- All Python packages mentioned in the Pi Hat setup tutorial (tinycircuits-wireling, Adafruit-Blinka, adafruit-circuitpython-ads1x15, and adafruit-circuitpython-busdevice)
- SX1505 Python Package (Used for both the Joystick and Rotary Wireling)
- Joystick Python Example Program
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.
Install the necessary Python package:
pip3 install tinycircuits-sx1505
Then you can download (above under Software) the Joystick Wireling example:
# 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)
Navigate in the terminal to the directory with the file parent to the examples folder.
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.
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!