Control AC Devices ...
Clear all

Control AC Devices with Arduino SAFELY - Relays & Solid State Switches  

DroneBot Workshop
Workshop Guru Admin
Joined: 2 years ago
Posts: 987
Topic starter  

Learn how to safely control AC devices using an Arduino. I will show you how to safely experiment with solid state switches and relays. We’ll also build a light-operate relay and a marquis-style light chaser!

Detailed article with code samples:

** I had a few sound issues with some of the experiment scenes, the isolation transformer I was using interfered with one of my microphones, so I had to back it off and apply a sharp 60Hz parametric filter. I apologize if it sounds a bit weird in spots! **

In an earlier video, I showed you how to control DC devices with an Arduino using BJTs and MOSFETs. Today we will learn how to control Alternating Current or AC devices. And, most importantly, I’ll show you how to experiment with AC in a safe and controlled fashion.

Controlling AC using semiconductors is a challenge, as most transistors only conduct current in one direction. One type of semiconductor that will do the job is the TRIAC, which itself is essentially a fusion of two Silicon Controlled Rectifiers, or SCRs.

Another way of controlling AC (or DC for that matter) is a good old-fashioned relay. Although relays have been around for over 180 years they are still a popular and practical solution for controlling AC devices.

One extremely important issue when controlling line-voltage (or mains voltage, if you prefer) AC current is isolation. You need to make absolutely sure that there is no electrical connection between your low-voltage logic circuitry and the high-voltage AC.

An excellent device for achieving this isolation is an optoisolator. This device separates the two circuits with a beam of infrared light, completely isolating them.

Put an optoisolator together with a TRIAC and you have a Solid State Switch, or Solid State Relay (SSR). Combine an optoisolator with a relay and driver transistor and you have a Relay Module. We’ll be using both of these devices with an Arduino today.

Here is the Table of Contents for today's video:

00:00 - Introduction
03:06 - Controlling AC
08:00 - Alternating Current Safety
09:28 - My AC Workbench Setup
12:39 - Using Relays
16:34 - Arduino Light-Controlled Relay
24:29 - Using Solid State Switches
28:43 - Arduino Light Chaser
36:24 - IoT Relay

The last item, the “IoT Relay”, is a commercial product that allows you to safely switch any AC device without having to build anything. It’s certified for use in the US and Canada and is perfect for those who just want to get the job done, or who are uncomfortable working with high-voltage AC.

It also lets you use the Blink sketch to flash a desk-lamp!

Hope you enjoy the video, if you want the sketches I used please see the article on the DroneBot Workshop website at

"Never trust a computer you can’t throw out a window." — Steve Wozniak

Active Member
Joined: 1 year ago
Posts: 6

Hi electronics wizards,


I try to switch 2 12V DC LED lights with a SSR (OMRON G3MB -202P but it does not work. The LED on the board goes on and off but not the connected LED strip. Then I saw on the SSR a reference to AC 240V/2A on the output. Did I make a mistake and can a SSR only switch AC?


I will switch to an optical relay module ( ). Can I e.g. switch DC on relay 1 & 2 and 220V AC on relay 3 & 4 independently?



PS better to be safe then sorry (and in the hospital ... :S)

PPS tx for this forum where stupid questions are allowed 🙂