Other Arduino Codes and Videos by Robojax

Introduction to 5V 1 channel Relay for Arduino (with power light)

The source code for stepper Introduction to 5V 1 channel Relay for Arduino


// April 01, 2017
 // Written by Ahmad Shamshiri for Robojax.com video 
 // Introduction to 5V relay.
 // Watch video for this code: https://www.youtube.com/watch?v=7tUGUXyloXQ
/* 
 * Please keep this note with the code.
 * This code is available on Robojax.com
 * 
 * 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 .
 */
 
int relayPin = 8;// define output pin for relay 

void setup() {
  pinMode(relayPin, OUTPUT);// define pin 8 as output

}

void loop() {
  
  digitalWrite(relayPin, LOW); // turn the relay ON (low is ON if relay is LOW trigger. change it to HIGH if you have got HIGH trigger relay)

  delay(500); // wait for 500 millisecond
 digitalWrite(relayPin, HIGH);// // turn the relay OFF (HIGH is OFF if relay is LOW trigger. change it to LOW if you have got HIGH trigger relay)
 delay(500);// wait for 500 millisecond
}

   

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