Joycoders (Alps RKJ "Funky Switch")
A Joycoder is the funky switch you find on a lot of sim-racing button boxes, mid-range stream decks and similar panels — Alps' RKJ-XT family. Mechanically it's a single thumbable head that combines two inputs:
- a 5-way navigation switch — push the head Up / Left / Down / Right or press it straight in (centre);
- a mechanical rotary encoder (1 pulse per detent) around the same shaft.
Out of the part it's 9 contacts (5 directional, 2 encoder A/B, plus 2 commons). NodeBlue ships one module for the Joycoder — nJoycoder — which assumes the ElectroSeed PCB. When the board has enough pins to wire the RKJ directly, you skip the template and build the chain from primitives; an example shows the pattern.
Two ways to wire it
| Wiring | GPIOs | NodeBlue side | When |
|---|---|---|---|
| Through the ElectroSeed PCB | 3 pins — 1 analog + 2 digital | nJoycoder template module. | Default. Any project using a pre-made board — you drop the PCB into your assembly and wire 3 pins to the MCU. |
| Direct, no PCB | 7 pins — 5 digital (directions) + 2 digital (encoder A/B) | No dedicated module: assemble the chain by hand. See the JoycoderRaw example for the canonical layout. | Only when you're designing your own PCB and have the spare MCU pins. The RKJ isn't an SMD part, but its pins are short and not meant to be soldered onto wires — without a PCB to land on, hand-wiring it isn't practical. |
The ElectroSeed resistor-ladder PCB
The companion PCB ElectroSeed sells works like this:
- Each of the 5 directional contacts is wired to the common rail through a different resistor in a resistor ladder.
- Whichever contact is closed pulls the analog output to its own voltage — five distinct voltage levels, plus a "no button pressed" level.
- The analog pin samples that voltage; the firmware identifies which button is down by which voltage range the sample lands in.
- The PCB only handles the directional buttons. The two encoder pins (A / B) come straight off the PCB to digital GPIOs — the rotary signal is too fast and too quadrature-coded to compress through the resistor ladder.
The PCB also adds a pull-down resistor on the common pin — the same stability fix described in the rotary-switch section of the Encoders tutorial: between two button states the common is floating and would pick up noise as an antenna; the pull-down clamps it to ground so the analog read is 0 (no button), never a ghost direction.
Result: five buttons read with one analog pin, the encoder kept on its native two digital pins — 3 pins total.
Internals of nJoycoder
nJoycoder is a template module — under the hood it wires together a small fixed chain you could in principle build by hand:
nAnalogInput(samples the ladder voltage) →nResLadder(decides which of the 5 buttons that voltage corresponds to) →nDeMultiplexer(fans the active button out to one output per direction) → the five button outputs.Separately: encoder A / B pins →
nRotKnob(1 ppd, counts the encoder pulses into a value) →nPosToPulses(emits the Inc / Dec outputs as wider, software-friendly pulses — see the encoders tutorial → Position → pulses).
Wiring inputs into the template hides this entirely; the user only sees the 7 output ports.
The "direct" wiring (no PCB) needs the same chain but with the resistor-ladder front-end replaced by five plain digital inputs. The JoycoderRaw example shows exactly that layout.
Parameters
| Parameter | Description |
|---|---|
| Pin (analog) | ADC pin reading the resistor-ladder voltage. |
| A Pin / B Pin | Digital GPIOs reading the encoder's quadrature signals. |
| Pulse duration | Width (in tens of µs) of each Inc / Dec output pulse — see nPosToPulses. Same fixed-width-for-every-pulse semantics. |
| Debounce | Direction-button debounce time, in ms. |
| Average / ADC Ref / ADC Resolution | Analog-front-end tuning for the resistor-ladder read. |
Outputs
| Output | What it carries |
|---|---|
| Up / Left / Down / Right / Push | Directional button states (0 / 1), each on its own port — wire straight into the corresponding HID buttons. |
| Inc | One pulse per clockwise detent — wire into a HID button you'll use as "up". |
| Dec | One pulse per anti-clockwise detent — wire into a HID button you'll use as "down". |
| msg | A status / diagnostic stream, mainly useful while bringing a board up. |
For a USB gamepad the canonical chain is the HID tutorial's buffer pattern — button signals → nBitPacker → nSerializer → nHID — with the seven Joycoder outputs feeding the nBitPacker.
Examples
- Examples/02-Digital/Joycoder — the ElectroSeed PCB path using the
nJoycodertemplate: one analog pin + two encoder pins. - Examples/02-Digital/JoycoderRaw — direct seven-pin wiring with no resistor ladder, built from the primitives by hand. Use it as a template for boards with pins to spare. The examples/09-USB/RKJXT1F42001 file is the same project, copied into the USB folder under the Alps part number so it's also discoverable when you're browsing HID examples.
Next: Range, Calibration & Spline — turning the raw values that come out of every input device into clean, calibrated, downstream-ready signals.