Arduino Microcontrollers can be used to control remote devices using an Integrated Circuit known as an Optocoupler (Optoisolator). On the input side of the optocoupler you are powering or not powering an LED, which when lit up, closes a switch on the other side of the optocoupler! This allows you to have two electrically isolated circuits with one device.
Be sure to leave a like on the video, subscribe to the channel and consider checking out my Patreon link below: https://www.patreon.com/LeMasterTech
Drop a comment if you have any questions, want to suggest something for future videos or want to roast me for saying Octocoupler instead of Optocoupler so many times!
what's up you guys welcome back to the
channel in today's video I'm going to
show you how to use an Arduino to
control buttons on external devices off
on
[Music]
so the summary of how this circuit works
all boils down to this little integrated
circuit called an octocoupler now the
way an octocoupler works is it lets you
control two different circuits
completely electrically isolated from
one another because pin one to pin two
has an LED in it and so when this gives
off light pin 4 to 5 and 6 closes a
switch that means five and six get
connected when this led is lit up so by
turning an Arduino signal onto pin one
and then connecting pin two to ground so
we have an Arduino output here and
ground here we are making five connected
to six basically a continuation of a
piece of wire so we can use this to make
a button or some device in the field
turn on by using our Arduino signal even
if we have nothing electrical in common
across the two so to really summarize
all we have to do in this circuit is
connect an Arduino output pin
through a resistor of about 220 ohms
because it needs to be about the same
that you would use to turn on an LED
outside your board and then pin 2 will
go back to our ground and then what
we're going to do is take pins five and
six
and we're going to put these on the two
pads of our external button
and to quickly explain how basic buttons
work especially in things like remotes
they're typically just thin pads of
metal that when you press down actually
connect two different pieces so I will
try to get the camera to focus but so
actually underneath these pads on a
remote there's usually two different
contacts that you need to have be made
and joined together so the Outer Circle
and the inner circle on these buttons
are what we're actually joining together
when we push any of the buttons in on a
remote therefore by touching one of the
wires from pin five or six to the Inner
Circle and one of the wires from pin
five or six to the Outer Circle our octo
coupler will complete this circuit when
our Arduino tells it to turn on and off
really quick and hopefully obvious
disclaimer please do not just tear into
random remotes that you really really
need because as part of this project you
may want to solder the leads on if it's
something you want to permanently
control but can controlling an external
device from an Arduino can sometimes
make it to where you can't easily go
back to the previous state so I took the
rubber pads off of this remote and the
whole face of it it's for a pretty uh
crappy Verizon Stream box that came free
with my internet as you'll see a little
bit later when we demo it but please
don't just tear into any random thing to
proof of concept this okay you can
essentially control any button on any
device but please don't cut into your
blender or household appliance or your
only TV remote or something essential to
mess around with this project you may
never be able to put things back exactly
the way you had them so I am adding one
layer of complexity to my Circuit by
using one of these three pronged sound
detectors and the way this works is you
provide voltage and ground on two of the
pins and then it has a little microphone
that detects sound in your area and
depending on whether or not it passes a
certain threshold it will turn on or off
this digital output pin and then the
resistivity is also adjustable with this
little potentiometer here so you can
tweak it up or down if it's too
sensitive and you need it to be more or
less sensitive but this way by putting
this in my circuit I'll be able to turn
the button on or off using an audio
input and this is not a piece that
standard light comes in a beginner
Arduino kit but I will leave a link to
Amazon you can get like five of these
for five dollars so this is not a big
ticket item that I'm using here okay and
then really the only other things we
have to put in our circuit are of course
the octocoupler itself and some of them
have a u cut out of them like other
integrated circuits we've seen in the
past but some of them just have a little
dot to indicate where pin one is so you
need to make sure that you're aware of
where pin one is on your octo coupler
but other than that it's a bunch of very
simple connections okay so I'm going to
start by putting a 220 Ohm resistor in
line with if my pin one on the Octo
coupler so this is to make sure that
when we want to turn on the LED inside
the Octo coupler we go through a
resistor first so we don't short this
thing by putting too much current on
there now I also want to do
um I want to put an LED in line with
this resistor as well so that we can see
on the outside world what the internal
LED is doing okay so this is just kind
of a neat idea that I'm using so that we
can see visually if our output is on
this could also potentially help with
troubleshooting if there's any issues
okay so with our octocoupler on the
board the microphone on the board and
then the LED and the resistor in line
with pin one of the Octo coupler the
only things left to do really are
determine where the power and then where
the input and output wires need to go so
I'm going to start by bringing ground
over to this first Power rail and then
I'm going to put Power
on the power rail right next to our
ground the positive row now I'm going to
connect pin 2 of the Octo coupler to
ground
and now I'm going to connect the ground
pin of our microphones noise detector to
ground as well and now I'm going to
connect the positive voltage pin of our
noise detector to the positive voltage
lead and now I'm going to connect the
leg of the LED which remember will go
through the resistor and then to the
Octo coupler when the output is on and
I'm going to have that connected to pin
2. although you can use any digital pin
on your Arduino that you want now I'm
going to connect the output from our
sound piece into our Arduino onto the
pin 8 of our Arduino but again you can
use any digital pin we'll just use 8 as
the input and then the only thing left
to do is that you want to put your two
wires that you plan on hooking your
buttons up to in the field connected to
pins five and six of your octo coupler
and now the only thing remaining to do
in this basic circuit is uh take care of
the code and get the code uploaded to
our Arduino and then actually hook up
our octo coupler output pins to our
button in the field and see if it's
working all right so the code for this
project or the sketch in the Arduino IDE
is incredibly simple so rather than type
it line by line with you guys I'm just
going to go through the sections there
will also be a link to this in the
GitHub description of this video below
as well
um so you can just grab it if you want
to do the exact same one as me but
basically the only three variables we
need to set up in the beginning are
whatever pin we're using to control the
Octo coupler and so for me that's going
to be pin two whatever pin we are
listening to the microphone input from
and that's going to be pin 8 for my
build and then I'm just creating an
interval to track the state of our um of
our uh push button so whether it should
be on or off noise state
now in the setup code which just runs
once at the beginning of the kind of
boot up of the machine first time it's
powered on we're going to set our
octocoupler control pin to an output and
then our noise pin that we're monitoring
to an input and then I'm just doing this
serial dot begin so that I can monitor
and see if everything's working properly
from my uh from my serial console window
to actively monitor the Arduino and then
in the loop section of the build which
is uh going to run repeatedly over and
over and over until we stop it or power
it down I'm just going to start by
reading the noise pin right so these
noise Gates that I got in particular
there will be a link to them they're
like five for five dollars in the
description of the video as well but if
the noise state is zero because they're
normally on so if everything is quiet
you'll be getting a one and then when
noise is made it'll break that and it'll
go to a zero so when the noise state is
zero for the first time like you just
said something we're going to turn on
the octocoupler and then I'm going to
print a one in the window so I know we
just turn something on and then I'm just
going to wait a tenth of a second so
that if it's like flickering because
you're making noise and then not making
noise and then making noise and not
making noise it'll only run once so I'm
just going to delay a tenth of a second
or 100 milliseconds
and then I'm going to write it back to
low uh so basically that's just one
section of turning a button on for a
tenth of a second and then I will print
a zero to let me know in the window that
it should be back to off and then last
thing I did is I just delayed it by a
period of 10 milliseconds
um because I just want it to only read a
maximum of 100 times per second if it's
reading trying to read as fast as
humanly possible then you're going to
get a lot of noise and interference so
this is just a time delay buffer so that
nothing funky happens okay but that's
the entire code so now we just need to
plug it into our Arduino upload it and
see if our circuit is working as
expected okay so we just powered it up
and this is actually kind of cool you
can see this led is reacting pretty much
directly with my voice and I don't know
if the camera can see this or not but
the microphone sensor also has an LED on
it that is also mimicking it but the
difference is this could flash really
really fast the green light is going to
flash at increments of one tenth of a
second okay so that verifies that our
signal is turning on and off kind of the
way we want to but if I take the two
wires hopefully the camera is picking up
that there is a red LED indicator light
that is turning on every time our octo
coupler turns on and I'll show in a
separate view that this is actively
turning on and off the Verizon Stream
box every time you see that red light
blink on
off
on
off so to quickly summarize this super
fun really useful but also surprisingly
simple build we just need an integrated
circuit known as an octo coupler for my
specific application using a microphone
input you need a sound detector and then
you're going to use one digital input
and one digital output with your Arduino
one to read the input from The Sound
sensor and one to control the state of
the octocoupler and then two wires
coming off of octocoupler uh terminals
five and six to go out to your button in
the field and then less than 20 lines of
code which again you can get from the
GitHub Link in the description of this
video below and just like that you can
quickly control any button on any device
anywhere with just a simple Arduino I
hope you guys had fun making this
project I hope you got what you were
looking for out of this video be sure to
let me know in the comments below if you
had any questions on what you saw in
this video or suggestions for what you'd
like to see in the future on the channel
don't forget to leave a like on the
video subscribe to the channel I'll see
you next time thanks bye