need help with 2 optical audio outputs, 1 input

hi, guys

i want my speak hook up to a switch box , than the box will have two source of input with a aux port, computer & phone.

how can i do this, can i just get a 2 to 1 splitter then put a switch between them to switch which source i want to use?

what kind of switch?

Thank

I assume you want to control it with the Arduino?
Switching optical audio is hard (if you look on amazon, the cheaper optical audio switches are purely physical - they're switching the audio with this dial that physically points the fiber that the input goes into at the selected output). I would recommend taking a commercially available optical audio switch and using that.

You need an electronic optical audio switch - one that requires a power supply. (example, not product endorsement: Amazon.com ), and hijack the button to control it. One side of the button will probably be tied to ground, and the other pulled up to VCC (hopefully 5v, which is likely since it's got a 5v supply), so pressing the switch will ground both sides (check with multimeter to make sure this is what it's doing).

Assuming all those assumptions I made are true, tie switch ground to arduino ground, and run the other side of the switch to any output pin, and pulse it low to simulate pressing the button. If you need to, you could get on the LEDs to figure out which connection is active.

Alternately, many of the electronic optical switches have an IR remote, and if you could do everything with the remote, there is a great volume of material on using Arduinos to replace IR remote controls.

The TOSLINK signals isn't that hard to work with. I made a toslink-splitter to split signal from a TV to a soundbar and surround amplifier. The commercial units were even crap or expensive (save your money, don't buy a passive unit, they are utterly shit!)

Switching between two signals i reckon could be done with a 4051/4052

I found this: DIY: 3 in, 1 out spdif toslink switch - a photo on Flickriver

// Per