The Joystick module is similar to analog joysticks found in gamepads. It is made made by mounting two potentiometers at a 90 degrees angle. The potentiometers are connected to a short stick centered by springs.

Output: This module will output roughly 2.5 volts from both outputs when in its resting position. Moving the stick will cause the outputs to change from 0v to 5v depending on its direction. If you connect this module to an Arduino through the Tinkerkit Shield, you can expect to read a value of roughly 512 in its resting position (expect small variations due to tiny imprecisions of the springs and mechanism) When you move the joystick you should see the values change from 0 to 1023 depending on its position.

Module Description: This module features two 4k7 Ohm linear potentiometers, two standard TinkerKit 3pin connector, two signal amplifiers, a green LED that signals that the module is correctly powered and two yellow LED whose brightness depends on the values output by the module.

Available methods

TKJoystick joystick(I0, I1);
readX() return the joystick x-axis reanding. It is an analog value from 0 to 1023
readY() return the joystick y-axis reanding. It is an analog value from 0 to 1023


// include the TinkerKit library
#include <TinkerKit.h>

// creating the object 'joystick' that belongs to the 'TKJoystick' class
TKJoystick joystick(I0, I1);   

// creating the objects 'xLed' & 'yLed' that both belongs to the 'TKLed' class
TKLed xLed(O0), yLed(O1);      

// a variable for the Joystick's x value
int x = 0;      
// a variable for the Joystick's y value
int y = 0;     

void setup() 
  // initialize serial communications at 9600 bps

void loop()
  // read the both joystick axis values:
  x = joystick.readX();  
  y = joystick.readY(); 

  // set the leds brightness

  // print the results to the serial monitor:
  Serial.print("Joystick X = " );                       
  Serial.print("\t Joystick Y = " );                       

  // wait 10 milliseconds before the next loop