Function: what the KY-023 does in a circuit
A thumb stick like the one on a game controller: two analog outputs for left–right and up–down, and a push switch.
- Reports left–right and up–down position
- Has a push switch under the stick
- Steers robots, games and camera mounts
KY-023 key facts
| Supply | 3.3 V to 5 V |
|---|---|
| Axes | two 10 kΩ potentiometers |
| At rest | about half the supply on VRx and VRy (512 of 1023) |
| Switch | SW connects to GND when pressed |
| Pins | GND, +5V, VRx, VRy, SW |
KY-023 pinout
The legs from left to right, as the part is drawn in the simulator:
| No. | Name |
|---|---|
| 1 | GND |
| 2 | +5V |
| 3 | VRx (left–right) |
| 4 | VRy (up–down) |
| 5 | SW (push switch) |
How it works
The stick turns two 10 kΩ potentiometers at right angles. Each one is a voltage divider: at rest VRx and VRy sit at half the supply (about 512 from analogRead), and they move towards 0 or 1023 as you push the stick. Pressing the stick down closes a switch that connects SW to GND, so read SW with pinMode(pin, INPUT_PULLUP): it is LOW when pressed. Springs bring the stick back to the centre.
What it is made of
- Potentiometers: Carbon resistive tracks with metal wipers CCuNi
- Stick and cap: Steel shaft with a rubber or plastic cap FeCH
- Board: Glass-fibre and epoxy circuit board SiOC
Where the materials come from: Carbon from petroleum coke or graphite; copper and nickel from their ores; iron from iron ore (Australia, Brazil).
The chemistry
The resistive track is carbon particles in a binder. The wiper touches it part-way along, so the output voltage is a fraction of the supply.
Biology connection
Moving a joystick precisely uses pairs of muscles that pull against each other, guided by position sensors in your joints. Muscles and levers →
Safety and the environment
The centre is rarely exactly 512: allow a "dead zone" of about ±30 around it in your code. Do not connect SW to 5V.
Did you know? Most analog sticks in game controllers work this way, though newer ones use magnets and Hall-effect sensors, which do not wear out.
Wave simulatorMomentum simulator Elements inside: CCuNiFeHSiO
Try it in the simulator
Build and code a circuit with a Joystick module in these practice projects:
Questions students ask
What does the KY-023 do?
A thumb stick like the one on a game controller: two analog outputs for left–right and up–down, and a push switch. Main functions: reports left–right and up–down position; has a push switch under the stick; steers robots, games and camera mounts.
How do I read a joystick module?
Connect VRx and VRy to two analog pins and read them with analogRead(): about 512 at rest, 0 or 1023 at the ends. Connect SW to a digital pin set to INPUT_PULLUP: it reads LOW while the stick is pressed.
What are the connections of the KY-023?
In order: GND, +5V, VRx (left–right), VRy (up–down), SW (push switch).
How does the KY-023 work?
The stick turns two 10 kΩ potentiometers at right angles. Each one is a voltage divider: at rest VRx and VRy sit at half the supply (about 512 from analogRead), and they move towards 0 or 1023 as you push the stick. Pressing the stick down closes a switch that connects SW to GND, so read SW with pinMode(pin, INPUT_PULLUP): it is LOW when pressed. Springs bring the stick back to the centre.
What is the KY-023 made of?
Potentiometers: Carbon resistive tracks with metal wipers. Stick and cap: Steel shaft with a rubber or plastic cap. Board: Glass-fibre and epoxy circuit board.
Is the KY-023 safe? How should it be recycled?
The centre is rarely exactly 512: allow a "dead zone" of about ±30 around it in your code. Do not connect SW to 5V.
More switches and controls
Connected tools
The same idea from another angle, across the site.