Multiplexers and De-multiplexers
A multiplexer picks one of several inputs based on a Select value and forwards it to a single output. A de-multiplexer does the reverse: takes one input and routes it to one of several outputs based on Select. Same idea as the silicon chips of the same name (74HC151, 74HC138 …), but applied to NodeBlue values flowing through a project. They keep flows tidy whenever you have one of N or N of one dispatching to do.
NodeBlue ships three modules:
| Module | Role |
|---|---|
| nMultiplexer | N data inputs + 1 select input → 1 output. The selected input's value is what comes out. |
| nMultiplexers | Multiple nMultiplexers sharing a single select input — useful when the same selector picks for several parallel streams. |
| nDeMultiplexer | 1 data input + 1 select input → N outputs. The data is routed to the output indexed by Select; the others stay at their last value (or 0, depending on configuration). |
nMultiplexer — one of N
The classic selector. The number of data inputs is Nb Inputs; a separate Select input picks which one passes through.
| Parameter | Description |
|---|---|
| Type | The numeric type of the data inputs (u8, s16, f32, …). All inputs share the type. |
| Nb Inputs | How many data inputs the multiplexer has (right-click → Add Input to grow it). |
| Sync | Usually InputSync so the output updates only when something changes. |
Common patterns:
- Mode-dependent value source. A rotary mode switch drives Select; each input is the value to use in that mode (raw / filtered / fixed test value).
- Mute / pass-through. Two inputs: a Constant(0) on input 0, the live signal on input 1. A Toggle picks; you have a mute switch.
- Active-source selection. Three sensor outputs into a 3-input Mux; a Number Selector dashboard widget drives Select. Now the dashboard picks which sensor's value the downstream chain sees.
nMultiplexers — many muxes, one select
When you have several parallel streams and want them all selected by the same control signal, nMultiplexers packages it into one module — Nb Multiplexers independent muxes, each with Nb Inputs inputs, sharing a single Select. Same behaviour as N copies of nMultiplexer, but on one tile instead of N.
Typical use: a six-axis IMU where you want to switch between "raw" and "fused" values for all six axes at once. One control toggle, six values change together.
nDeMultiplexer — one to N
The reverse: one data input, one select input, N data outputs. Whatever arrives on the data input is forwarded to the output indexed by Select; the other outputs hold their last value (or reset to 0 — module-configurable).
| Parameter | Description |
|---|---|
| Type | Data type of the input / outputs. |
| Nb Outputs | How many outputs to fan out to. |
| Sync | Usually InputSync. |
Patterns:
- Routing a single button to one of several actions. Button → data; mode rotary → Select; outputs wired to each action's input. Press while in mode 0 fires action 0, etc.
- Logging. Data input is a metric; Select is a "channel index"; outputs go to several Format/Serial chains so values are categorised by channel before display.
See Examples/11-Data/Demux for the minimal wiring.
Buffer multiplexing
For Buffer-typed flows (text, packed binary, serial frames) there's also Examples/11-Data/BufferMultiplexer — same idea but on buffer streams rather than scalars. Useful when you have several text producers (a FormatText for each subsystem) and one serial output, and want a Select-driven channel chooser without wiring every producer through a separate USBSerial.
Picking the right one
| If you have… | Reach for… |
|---|---|
| N data sources → 1 sink, with a control selecting which source | nMultiplexer |
| N parallel "swarms" all sharing one Select | nMultiplexers |
| 1 data source → N sinks, with control picking which sink | nDeMultiplexer |
| N buffer streams → 1 sink, Select-driven | BufferMultiplexer pattern (see example) |
Next up: the data-packing modules that complement these — Serializers, Packers, BufferSplit/Merge and friends.