Josh From BreakoutBros.com
Published © CC BY-NC

Control Your Lights With Arduino And A Relay

Why use a relay module when plain relays are cheaper? We will show you how to control your lights with an Arduino.

BeginnerProtip1 hour40,838
Control Your Lights With Arduino And A Relay

Things used in this project

Story

Read more

Schematics

Schematic

Code

Code snippet #1

C/C++
// BreakoutBros Relay Tutorial 
// 2016
//This tutorial is using the RoboRed Arduino from Yourduino
//Along with parts from the Elegoo Uno R3 Complete Starter Kit


void setup() {
 // initialize digital pin 3 as an output.
 pinMode(3, OUTPUT); 
}

//The main loop will continue to run until the arduino loses power
void loop() {
 digitalWrite(3, LOW); // turn the relay off to start
 delay(3000); // wait for 3 seconds
 digitalWrite(3, HIGH); // turn the relay on to turn on the light
 delay(3000); // wait for 3 seconds 
 
}

Credits

Josh From BreakoutBros.com

Josh From BreakoutBros.com

14 projects • 70 followers
At BreakoutBros we try to be a link between electronics designers and hobbyists. We make electronics tinkering easy for everyone but teach professional methods.

Comments