How can I set a wire to one of 3 voltages from a simple digital controller (e.g. Raspberry Pi)?
Two SPDT relays can be used to select the voltages like this:







simulate this circuit &ndash; Schematic created using CircuitLab

You will normally require transistors to drive the relays, as most microcontroller outputs cannot handle a relay's coil current.

With GPIO2 Low, "7 V" will be selected. GPIO1 will have no effect.

With GPIO2 High and GPIO1 Low, "6 V" will be selected

With GPIO2 High and GPIO1 High, "5 V" will be selected