How to switch higher-voltage loads with an Arduino (relay, optocoupler, H-bridge)

Based on contributions by Ilmar.

An Arduino’s digital pins only supply 5V at a few tens of milliamps, so you cannot drive higher-voltage motors, lamps, or mains-powered equipment directly from a pin. This guide compares the three most common ways to let a low-voltage Arduino signal switch a higher-voltage circuit.

What you need

  • A relay, optocoupler, or H-bridge module, depending on which approach you choose
  • A separate power source at the voltage your load requires
  • Basic wiring/breadboard equipment

Steps

1. Choose a relay for simple on/off switching

A relay is the easiest option and there are always some available in the robot lab. It can switch both AC and DC loads at relatively high voltage.

A relay has two separate circuits: a low-voltage coil circuit (driven by the Arduino) and a high-voltage switch circuit (driven by your load’s power source). When the Arduino outputs 5V, the coil energizes and pulls a normally-open switch closed, allowing current to flow through the load’s power line. If you drive the coil with a PWM/AC-like signal, the switch will open and close rapidly, which can be used to produce an AC-like signal in the power line.

Use a relay when you just need to turn something on or off and don’t need fast switching.

2. Choose an optocoupler for a cleaner, faster switch

An optocoupler works on the same principle as a relay — two isolated circuits, one on the Arduino side and one on the power side — but instead of a coil and a mechanical switch, it uses an LED and a phototransistor to open and close the high-voltage circuit. Because there’s no magnetized coil or moving contact, it switches faster and is preferred in more sensitive setups. It works for both AC and DC circuits.

See this short video for a visual explanation.

3. Choose an H-bridge to drive a motor in both directions

An H-bridge is effectively a set of four switches (often relay- or transistor-based) arranged so a motor can be driven in either direction — useful whenever you need a motor to turn both ways, not just on/off.

To turn the motor, current must flow through it, so you switch on diagonal pairs of transistors together: switching on Q1 and Q4 drives current from + to − through the motor (one direction); switching on Q2 and Q3 reverses it (the other direction). Never switch on Q1+Q2 or Q3+Q4 at the same time — that short-circuits the supply.

See this short video for a visual explanation.

Related


Rewritten and consolidated (Sept 2026) from the original student how-to’s: How to control higher voltage components with an arduino.