Part

Thumb stick

Two axes and a push switch. Drag the cap to move it.

See every part
  • 5 pins
  • In 15 projects
  • In 3 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Thumb stick in brief

What it is, and where it sits on the bench.

The KY-023 joystick module is two 10k potentiometers and a push switch under one thumb cap. Each pot sits across the supply with its wiper on VRX or VRY, so the axes are voltages read with analogRead: A0 and A1 on an Arduino Uno, giving 0 to 1023, or two ADC1 pins on an ESP32, giving 0 to 4095. Power it from 3.3 volts on an ESP32, or a stick pushed to one end puts 5 volts on an ADC pin. SW shorts to ground when the stick is pressed down and has no pull-up of its own, so it needs INPUT_PULLUP; reading it as a plain input is the usual mistake. Mokxi models each axis as a real divider across whatever VCC and GND hold, with a source impedance of zero at the ends and 2.5k at center. Drag the cap to move it and it springs back to exactly 512 of 1023. Real sticks never return to the same count, so they need a dead band this model does not, and SW never bounces here.

Family
Inputs
Pins
5

A circuit built around it, running and explained: the Joystick simulator.

Pins

5 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
GND
The other end of both tracks.
VCC
Supply for both potentiometer tracks.
VRX
The X-axis wiper.
VRY
The Y-axis wiper.
SW
Shorts to ground when pressed; open the rest of the time.
How to use it

How to use the KY-023 joystick with an Arduino

VCC to 5 V, GND to GND, VRX to A0, VRY to A1 and SW to a digital pin with INPUT_PULLUP, pin 12 here. analogRead() on each axis gives 0 to 1023, with the stick at rest near the middle. The bar graph example maps the X reading onto eight LEDs, and pressing the stick swaps it to the Y axis.

The mokxi_joystick.h driver wraps the three reads: x() and y() give the raw axes, dx() and dy() measure from where the stick rested at begin() with a dead zone, and clicked() reports a press once. The rest point is read rather than assumed because a real stick never springs back to exactly 512, so a sketch that steers from dx() and dy() does not creep.

Part pin
Board pin
VRX
A0
VRY
A1
SW
Pin 12
VCC
5 V
GND
GND

On an ESP32-C3, power the stick from 3.3 V and read the axes on ADC1 pins, 0 to 4095; the ESP32-C3 thumb stick example uses GPIO 0 and 1 with SW on GPIO 3.

Arduino Uno: joystick bar graphlive0.000 s 0.00x
Hold the button
This is the simulator itself, running here. Click anything to open it in the editor.
The stick from the bar graph example
#include "mokxi_joystick.h"
Joystick stick(A0, A1, 12);
void setup() {
  stick.begin();
}
void loop() {
  int raw = stick.x();   // 0..1023
  if (stick.clicked()) {
    // the stick was pressed
  }
}
How it is modeled

What is true about the Thumb stick, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

The wiper's source impedance is the two halves of the track in parallel (zero at the ends, 2.5 k at center for a 10 k pot), so an ADC input with a real load on it sees the module's actual impedance, not an idealized voltage. Both the Uno's ten-bit ADC and the ESP32-C3's twelve-bit ADC1 can read it, and mokxi_joystick.h in the firmware library hides the difference between 0 to 1023 and 0 to 4095.

Not modeled

No mechanical detent or spring rate beyond the springback itself, and no wear on the tracks.

The center is exact and silent. A real KY-023 does not spring back to the same count twice. It lands somewhere near the middle with a few counts of slop, and its wiper adds noise on top, which is why every thumb-stick sketch has a dead band in it. Here the release is exactly 512 of 1023 on both axes, every time, with no noise and no drift, so a sketch that would need a dead band on the bench works without one. The two tracks are perfectly linear and perfectly matched, where real ones are neither.

The track is an ideal divider: no wiper contact resistance, no end resistance, no scratchiness as it moves, and SW does not bounce even though the switch under a real one is a tactile dome.

From Thumb stick (joystick), in full.

Projects

See the Thumb stick in a project

15 built-in projects use it. Each opens in the editor, already wired.

Boards

The boards it is shown on

Each of these 3 boards has a built-in project with the Thumb stick in it.

Boards

The Thumb stick on each board

The pins, the voltage and the code change from board to board. Each page has that board’s wiring and a circuit you can run.

Wire up the Thumb stick

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.