Simplest Way to Create a switch with Arduino

I've got a couple projects in mind where I will be needing the Arduino to bridge a connection and I'm wondering when to use a transistor to do so or a relay.

Application one would be using the Arduino to selectively ground a music instrument signal. Sort of as a binary on/off kill switch. No audio would be passing through the component, but would (hopefully) be doing it very quickly (almost ringmod like on/off muting).

The second application would be using the Arduino to control a normal 'stomp' switch (momentary style BOSS switch). I'd like to have the Arduino control when the effect turns on and off. Again, no actual audio would pass through the switch, but it would do it quickly.

In general I'm not sure of when one would use a relay to accomplish switching in audio based applications. From my understanding relays can handle high voltages and such, but this isn't really needed in audio based applications.

Kind of depends on the voltage and current traveling threw the device. But either a transistor or a relay can be used. Generally relays are better suited for higher voltages. Like 12V or more. But you'll need to know how much voltage and current will be passing threw the connection no matter which one you choose.

In both it's very low. I don't know offhand but instrument signal is mVs.

Is there a speed difference between the 2 in general? Or rather, if you're dealing in low voltage, is there any reason to use a relay?

Given it’s an audio application - would the loud click of a relay be suitable? Transistors should be fine for your applications and have the added advantage of being silent and much, much faster.

That's exactly what I was curious about. Relays don't say "slow and loud pops in audio application" on the tin as it were.

Does having a transistor connected to an audio signal path effect the impedance or anything detrimental? If the transistor is switched 'off' that is.

Are there any schematics online for setting something like this up? The only 'transistor switch' diagrams I can find are using a transistor in conjunction with a relay, solenoid, or motor.

if you're dealing in low voltage, is there any reason to use a relay?

Yes, there are a few:

  1. Distortion: unless the relay is non-sealed, and the contacts get dirty, it'll pass the signal pretty much distortion-free. Solid-state switches will always add some, so you need to make sure you use a design by someone (not me) who knows how to make the amount of distortion "negligible".

  2. Isolation: with a relay, you can connect only the contacts to the "controlled" system. A solid-state switch usually requires that the controller and controlled share at least a common ground (although there are ways to avoid that requirement).

  3. "Fail safe": it's easy to design a relay-based switch so that it fails in the state you want (either open or closed) if no "controller" system is connected. You can do that with solid-state switches, too, but it's not always as simple.

These aren't absolute, hard-and-fast rules, of course: they're just design considerations to be weighed against other factors, like cost, power consumption, and that "popping" that can occur when switching with a relay.

Your mileage will vary.


Most of those reasons don't apply in your situation as you have no audio flowing. I would use an opto isolator:-

You're saying you would use an opto-isolator for audio usage, or non audio usage?

I am saying I would use an opto for what you want to do. That is to control an external device. All you have is switch control and the simplest way to do that is through an opto.

There is no audio flowing it is all on or off. The problem with putting aduio through an opto is that it is a non linear transfer function. Might make a good effects peddle thought. ;)

In the past I've switched audio input to my sound card just using an NPN transistor and resistor. Not high tech, but allowed me to watch the US incursion in Iraq on my tv at the house while at work. I'd suggest doing some cheap experimentation before getting to complex.

Would the transistor, and transistor part of the opto-isolator be wired ala LED to the arduino?

Not sure what you are saying. The transistor side of an opto isolator would be wired to the switch you are trying to trigger. Collector to the most positive side and emitter to the most negative side (normally ground). The other part of the opto isolator is an LED and this is wired up to the arduino just like you would an ordinary LED with a current limiting resistor.

Introductoin to opto-isolators… a valuable little chip… at…

That link shows a PNP transistor inside the opto isolator. These usually have an NPN transistor in them. Consequently the description of when you see high and low is backwards. It is described as if it were an NPN.