Other Arduino Codes and Videos by Robojax

How to control AC bulb with relay and Digispark USB board

How to control AC/DC Load using 5V Relay and Digispark USB board

This video explains how to control a 5V relay to turn ON or OFF an AC bulb or anything else like DC load.
  1. Start Using Digispark (video)

 /*
 Digispark Relay
 Turn a bulb, AC or DC load ON/OFF 

 Written by Ahmad Shamshiri at 18:21 on Saturday May 11, 2019 for Robojax
 in Ajax, Ontario, Canada
 www.Robojax.com
  Watch video instruction for this code: https://youtu.be/THgyVQE5yrA
 
*/


int relay = 0;// define a pin for relay output

// the setup function runs once when you press reset or power the board
void setup() {

  pinMode(relay, OUTPUT);// define "relay" as output
}

// the loop function runs over and over again forever
void loop() {

     digitalWrite(relay, LOW);// turn relay pin LOW (ON)
     delay(300);// give it a little time (100ms)

     digitalWrite(relay, HIGH);// turn relay pin HIGH (OFF)
     delay(300);// give it a little time (100ms)  
                 
}
   

If you found this tutorial helpful, please support me so I can continue creating content like this. You can support me on Patreon ( Launched June 14, 2019): http://bit.ly/2ZnITLz

Or support me via PayPal