How to Control an AC Bulb with a 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 a DC load. Start Using Digispark (video)191-How to control AC/DC loads using a 5V relay and Digispark USB board
语言: C++
/*
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 instructions 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)
}
资源与参考
-
外部开始使用Digispark(视频)youtu.be
文件📁
没有可用的文件。