Controlling LED with a Relay
This thread is for the continuation of a discussion in #general.
54 Replies
@prismlink Is your wiring complete? If so, can you post an image of the circuit before powering it up?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I would put some tape around that splice in the ground wire.
Then, you're going to have to make all of the connections between the relay and your arduino before you can run any tests.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View

Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yeah, just 3 wires.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
You can use this for now:
Should be something similar. 5v+, VCC, DC+. Something like that.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
DC+ = VCC
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Correct. 12 to IN, GND to GND.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
DC-
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Tools -> Port
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yes, that code turns the light on and off via the relay. 20 seconds on, 20 seconds off.
So, if the relay is clicking and your light is turning on and off, then everything is working.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
The light came with a power supply, right?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Oh, I remember you had one already. Yeah. You can plug it in and try it. You should see it turn on for 20 seconds, off for 20 seconds, repeating forever.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Everything is working?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ok, good. Now you can start working on the timer part of the project.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
With some kind of input. You can use buttons like you saw in the video, or a keypad. You could also use a potentiometer or rotary encoder. Whatever is easier for you.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
You might want to start with something simpler.
Here is a keypad example:
https://wokwi.com/projects/294980637632233994
Wokwi
keypad-input.ino - Wokwi Arduino and ESP32 Simulator
Run IoT and embedded projects in your browser: ESP32, Arduino, Pi Pico, and more. No installation required!
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
One button and a potentiometer would be pretty simple.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
It wouldn't be as precise. The knob could adjust from 5 to 30 minutes.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
You could just follow that project for everything else.
Wire up the 5 buttons and copy the code.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yeah, the other 4 buttons would be replaced with just one potentiometer.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Probably. You will have to search online.
I can create an example on wokwi.com, but I will be gone for a while starting in a couple minutes, so it might be a little while.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Do you have any switches?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
No, I mean an actual switch instead of a button. Would make more sense for on/off with a potentiometer.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
No, the kind that goes in your breadboard.
For the buttons, sure. The wiring and code is in the project hub link you sent.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
gtg for now. good luck.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I am online now.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
That is the way the code is written in that tutorial.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View