arcade kit/Buttons and joystick/06. Wire the joystick
Buttons and joystick · 06 of 11

Wire the joystick

The joystick is four microswitches round a lever. Push the handle up and the lever's lower end swings down into the switch nearest you, so that is the switch to wire to UP. A diagonal closes two.

Four buttons with a lever

To the mainboard, the joystick is four more buttons: UP, DOWN, LEFT and RIGHT are sockets like KEY1 to KEY10, with the same resistor and the same V(MCU). Each microswitch goes on one of them with one of the two-wire cables.

The switch on the far side

Push the handle, close the far switch
Up
Push the handle
The handle goes up, the actuator goes the other way, and the switch on the far side closes. That switch is the one to wire to UP. Wire by position instead and every direction comes out backwards.

The handle pivots in the middle of the housing. The part below the pivot, the actuator, moves the opposite way to the handle, and it is the actuator that presses the switches. Push up and the actuator presses the switch at the bottom, nearest you.

So wire the switch nearest you to UP, the far one to DOWN, the one on the right to LEFT and the one on the left to RIGHT. Then check with the input monitor rather than trusting the picture: push each way and read the name it prints.

UP pressed
UP released
LEFT pressed
LEFT released

The three tabs

Each microswitch has three tabs, usually marked COM, NO and NC. Use COM and NO: normally open, closed only while pushed. NC is the opposite, and a switch wired to it reads pressed until you push the stick.

Diagonals

Push the handle into a corner and the actuator presses two switches, so the monitor prints two directions. That is what a diagonal is. Whether your game treats it as a diagonal or keeps only one direction is a decision for the code, not the wiring.

When it does not work

Up and down are swapped

The two leads were wired by position. Power off, swap the leads on the UP and DOWN sockets, and check again with the input monitor. Do the same for LEFT and RIGHT if they are swapped too.

One direction reads pressed all the time

That switch is on COM and NC. Move the lead from NC to NO: NC is closed at rest, so it reads the opposite of what you want.

Does it matter which way round the two wires go?

No. A switch has no polarity: it joins its two terminals or it does not. Either wire of the pair can go on either tab.

The stick moves in eight directions but I only want four

Handle it in code. When two directions read HIGH at once, keep whichever was pressed first and ignore the second until the first is released. The wiring stays the same.

Where this goes next

A 12 V machine on a 3.3 V pin, and the diode that makes it safe.

Connect the acceptor

Edit this page — content/books/arcade/wire-the-joystick.mdx

Community

Questions about this product

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

Ask a question ↗

HotSwap Arcade Kit: Buttons, Joystick and Coin Acceptor for ESP32-S3, Nano, Pico and Zero 2 W

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