Back to Arduino Step By Step Course

Lesson 64: Using Solid State Relay with Arduino

If you don't like to see ads while video is being played you can purchase this course for $200 from Udemy or purchase YouTube premium Here

Part 6: Using Relay with Arduino

In this lesson we learn what Solid State Relay is and how to use it with Arduino to control an AC bulb. The wiring of a relay module is shown and code is explained.


  /*
  * Lesson 64: Using Solid State Relay  with Arduino 
 * This is code to control 2 channel Solid State Relay (SSR) module using Arduino
 * Written by Ahmad Shamshiri for Robojax.com 
 * on Feb 24, 2019 at 15:11 in Ajax, Ontario, Canada

  Watch instruction video for this code: https://youtu.be/DumIZ3lkHP4
  
  This video is part of Arduino Step by Step Course which starts here: https://youtu.be/-6qSrDUA5a8

 

If you found this tutorial helpful, please support me so I can continue creating 
content like this. You can support me on Patreon http://robojax.com/L/?id=63

or make donation using PayPal http://robojax.com/L/?id=64

 *  * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
 * This code has been download from Robojax.com
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

// Robojax 2ch SSR control 20190224
int ch1Pin = 2;// define pin 2 for chan 1 of SSR
int ch2Pin = 3;// define pin 3 for chan 2 of SSR

int triggerType = HIGH;// type LOW if low trigger and HIGH if high trigger SSR is used

int ssrON, ssrOFF;// used for two different SSR trigger type. Do not change

void setup() {
    // Robojax 2ch SSR control 20190224
    pinMode(ch1Pin, OUTPUT);//define ch1Pin as output
    pinMode(ch2Pin, OUTPUT);//define ch2Pin as output
    
    if(triggerType == HIGH)
    {
      ssrON = HIGH;
      ssrOFF = LOW;
    }else{
      ssrON = LOW;
      ssrOFF = HIGH; 
    }       
  // Robojax 2ch SSR control 20190224
   digitalWrite(ch1Pin,ssrOFF);// set initial state of SSR 1: OFF
   digitalWrite(ch2Pin,ssrOFF);// set initial state of SSR 2: OFF      
    
}

void loop() {
    // Robojax 2ch SSR control 20190224
    digitalWrite(ch1Pin,ssrON);// turn relay SSR1 ON
    digitalWrite(ch2Pin,ssrOFF);// turn relay SSR2 OFF    
    delay(3000);// waite for 3 seconds
    
    digitalWrite(ch1Pin,ssrOFF);// turn relay SSR1 OFF
    digitalWrite(ch2Pin,ssrON);// turn relay SSR2 ON    
    delay(3000);// waite for 3 seconds    


     
    // Robojax 2ch SSR control 20190224
   delay(1);
   

}// loop



   

The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps me. Thank you

If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal