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.
/*
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)
}