TK23ANALOGDIGITALbeginner

Dual Axis Joystick

A thumbstick on a square TinkerBlock board, on six pins: GND, VCC, NC, X, Y and SW. X and Y are two potentiometers from VCC to GND, read on analog pins; SW is the click under the stick, LOW at rest and HIGH when pressed, with its own pull-down. Every line reaches VCC, so VCC is your board's logic voltage. A PWR light and an SW light show power and each click.

Specifications

TypeTwo-axis thumbstick with a centre click, the kind used in games controllers: three inputs on three signal pins
StickTwo potentiometers from VCC to GND, one per axis, on X and Y. Rests near half of VCC; at least 60° of travel end to end on the supplier's drawing
ClickSW: a switch to VCC under the stick, with a pull-down on the board. LOW at rest, HIGH while pressed. Read it as INPUT, not INPUT_PULLUP
Lights2: PWR red, on whenever it has power, about 0.29 mA at 3.3 V and 0.63 mA at 5 V; SW blue, on while the stick is pressed, about 0.14 mA at 3.3 V and 0.47 mA at 5 V, so dim on a 3.3 V board. Worked out, not measured. Both work with no sketch running
Supply3.3 V or 5 V, the same as your board's logic: 3V3 beside an ESP32, ESP32-S3 or Pico, 5V on an Uno. Every signal can reach VCC
CurrentNot published. The stick's tracks take about 1 mA at 5 V if they are the 10 kΩ they are marked, and the red PWR light about 0.3 mA at 3.3 V and 0.6 mA at 5 V through its 5.1 kΩ resistor. While pressed, the pull-down adds VCC over 5.1 kΩ, about 0.65 mA at 3.3 V and 0.98 mA at 5 V, and the blue SW light about 0.14 mA and 0.47 mA more
Pins to wire5 of 6: VCC, GND, two analog inputs for X and Y, and one digital input for SW. NC is in no net
Header6 right-angle male pins, 2.54 mm pitch, along the bottom edge: GND, VCC, NC, X, Y, SW, with GND on the square pad
Board31.0 × 31.0 mm, square, with four 4.8 mm mounting holes 24 mm apart
HeightAbout 29 mm to the top of the cap, which is about 25 mm across (3D model)

What it is

A thumbstick on a square TinkerBlock board. The stick tilts along two axes and clicks when pushed straight down, so it is three inputs, and they come out on six pins: X, Y, SW, VCC, GND and NC.

The TK23 at an angle: a square black board with a large mounting hole in each corner, a tall black thumbstick with a domed cap rising from a square housing in the middle, a white potentiometer rotor visible on the housing's side, five small parts along the left edge labelled PULL-DOWN, SW and PWR, and a six-way header along the near edge.
The TK23. The header runs along the bottom edge; GND is its left-hand pin.

X and Y are two potentiometers under the stick, each a track from VCC to GND with a wiper the stick turns. Let go, each rests near half of VCC; tilted, it moves towards one end.

SW is a switch under the stick, to VCC, with a pull-down on the board. It reads LOW at rest and HIGH while pressed.

VCC is the ceiling of all three. Wire it to your board's own logic voltage: 3V3 beside an ESP32, an ESP32-S3 or a Pico, 5V on an Uno.

Which pin is which

Parts up, header along the bottom, reading left to right:

GNDto your board's GNDthe square pad: count from here
VCCto 5V on an Uno, 3V3 on the restevery signal can reach it
NCnothingin no net on the board
Xto an analog pinone axis of the stick
Yto an analog pinthe other axis
SWto a digital pinthe click. LOW at rest, HIGH pressed. INPUT, not INPUT_PULLUP

The back prints the same names mirrored, SW Y X NC VCC GND, with the square pad on the right, and three lines that sum up the board: X, Y ANALOG OUTPUT, SWITCH ACTIVE HIGH, PULL-DOWN BY RESISTOR.

Wiring

BoardXYSWVCC to
Arduino UnoA0A1D25V
ESP32GPIO 34GPIO 35GPIO 253V3
ESP32-S3GPIO 4GPIO 5GPIO 73V3
Raspberry Pi PicoGP26GP27GP153V3(OUT)

On the ESP32s, X and Y are on ADC1, which keeps working with Wi-Fi on. The red PWR light comes on as soon as VCC and GND are right.

Example

// Uno: A0 A1 2. ESP32: 34 35 25. ESP32-S3: 4 5 7. Pico: 26 27 15.
const int X_PIN = 4, Y_PIN = 5, SW_PIN = 7;
int centreX, centreY;

void setup() {
  Serial.begin(115200);
  pinMode(SW_PIN, INPUT);             // R10 on the board pulls it down
  delay(200);                         // hands off the stick
  centreX = analogRead(X_PIN);        // where this stick rests
  centreY = analogRead(Y_PIN);
}

void loop() {
  Serial.print("X ");
  Serial.print(analogRead(X_PIN) - centreX);
  Serial.print("  Y ");
  Serial.print(analogRead(Y_PIN) - centreY);
  Serial.print("  SW ");
  Serial.println(digitalRead(SW_PIN)); // 1 while pressed
  delay(200);
}

Let go, both numbers sit near 0. Push the stick each way to see which one moves and which way; press it and SW prints 1 and the blue SW light comes on.

Where to start

The handbook below is ten short articles, each with a working figure. The first read is the whole build in five wires, and VCC sets the top is the one wiring choice that can hurt a board.

For a stick that reads 0 when let go, a centre and a dead zone is the sketch. For a direction instead of two numbers, eight directions.

When it doesn’t work

Should VCC go to 5V or 3V3?
To whatever your board's pins run at: 3V3 on an ESP32, an ESP32-S3 or a Raspberry Pi Pico, 5V on an Arduino Uno. X and Y reach VCC at the ends of the travel and SW is joined to VCC on every click, and nothing on the board limits that. 5V beside a 3.3 V board overdrives its pins; 3V3 on an Uno is safe but only reaches about 675 of 1023.
SW reads LOW when I am not pressing it. Is that right?
Yes. A resistor on the board pulls SW down to 0 V, and pressing the stick straight down joins it to VCC. So it is LOW at rest and HIGH while pressed, the opposite of most buttons, and the back of the board says SWITCH ACTIVE HIGH. Set the pin to INPUT; INPUT_PULLUP would fight the resistor on the board.
Why does the stick not read exactly the middle when I let go?
No thumbstick does. Each axis springs back near the middle of its track, not onto it, and X and Y rest in slightly different places. Measure the centre when the sketch starts, with the stick let go, and treat anything within a few per cent of it as 0.
Which way does each axis go?
X and Y are the names of the two potentiometers, not directions. From where they sit on the supplier's drawing, X should follow the tilt towards and away from the header and Y the tilt left and right; which way each one rises is not on the drawing. The first sketch in the handbook prints both so you can push the stick each way and see.
What are the two lights for?
PWR, the red one, is on whenever VCC and GND are connected the right way round. SW, the blue one, is on while the stick is pressed; on a 3.3 V board it is dim, which is the resistor and the blue LED's higher drop, not a fault. Neither needs a sketch, so they split a fault in two: SW lighting while your sketch sees nothing means the wire or the pin number is wrong, not the board.
What do I leave unconnected?
NC, the third hole from GND. It is in no net on the board. Everything else gets a wire.

The dual axis joystick handbook

10 articles · about 45 minutes

This page is the reference: what the part is, what it is made of, and the questions people arrive already asking. The handbook is the walk — the same part in the order somebody actually meets it.

What is on the board

2 articles

Six pins, one of them NC, and a thumbstick on a square board 31 mm across: two potentiometers, a push switch, a pull-down and two lights.

The stick

3 articles

Two potentiometers from VCC to GND, so X and Y are shares of VCC and VCC has to match your board. And a click that reads HIGH, with a light that shows it.

Reading it

2 articles

Five wires and a sketch that prints X, Y and SW, then a centre measured at start-up and a dead zone around it.

Using it

3 articles

A click that counts once, eight directions from two numbers, and the short list of reasons a reading looks wrong.

Edit this page — content/modules/dual-axis-joystick.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Dual Axis Joystick

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum