Hi! welcome to another video tutorial from Robojax. in this video we are going to see how we
can turn on this AC bulb or load or maybe DC using infrared remote control and Arduino so
we turn it on and turn on the relay and relay will control this when I press the remote the
light is on and when I press the negative the light is off also I'm gonna show you
how you can use your own TV remote to turn on and turn off the light you can get the
code for this project by clicking at the link at the description below which will
take you to robojax.com/learn/arduino let's get started with this
but the whole purpose of this video is so you are able to use either the black remote control
or the white remote control and receiver with PCB or the receiver without the PCV this VF 18:38 be
to be able to turn on an AC bulb or maybe you can use your own TV remote to turn something on and
off so I have a video that has explained fully this one and the receivers are not gonna good
explaining all those so you have to watch that video making sure that you receive the signal
and on the serial monitor it prints and it works perfectly after that you come to this one so I can
go directly with the code of the portion that controls this and how to set the relay and the
code for controlling the relay which switch which switch to take action for I'm going to show you
how to set a specific button to do control the relay for example I've set the plus sign on this
white remote to turn the relay on and the minus to turn it off so you can set any of those you want
or maybe in this black remote you can put this a left arrow right arrow or top and bottom whichever
you prefer any of these buttons to be able to control with one button and turn it off with the
other one in many countries you cannot insert this plaque in the other way so live and neutral or
always on the same position but it does not make any difference in terms of safety because in many
devices or loads the current goes from one wire and even if you disconnect the life the life will
come back here it will appear here so which what it means is this is very dangerous to be touched
once the plug is connected to the outlet do not touch this relay if your if you want to work with
this disconnected and then work with the relays that's for safety purpose because safety is first
let me explain the AC bulb here so this is a table light attached to the wall outlet
and the wire goes and will be turned on but I've disconnected one of these two wires here I've just
cut this wire from here now this can be connected to that relay the relay job is to just connect it
so it will be on and disconnected will be off I've just twisted them and then put some solder
so this can be inserted into connectors with a screw to briefly explain the relay the relay has
treatment here for the load some of the more will have proper English writing this is Chinese but
it's just by chance that I got this but in this side it has been labeled properly so the three
pen that you are connecting here well here we have VCC we have ground and nvcc will be connected to 5
volts ground and this is connected to pin 2 on this side we have three wires three pens
so what happens is we will connect two wires that I showed you one of them will be here the
other one will be here either on this side or on that side in this side this is normally open
which means when the relay is energized it will turn on and this side this is normally connected
so as soon as you turn it on or maybe if the Arduino and everything is off it will always
have connection once you send the signal it will turn off so in case your device is behaving in
Reverse keep the middle while in a same position and just move your while from here to here but
for this project I will suggest to connect the wire in here and here because this is normally
connected these two wires are normally connected so you will connect between this and this which
is normally open and in terms of power that you can connect to this relay or any really
that you're using make sure to pay attention to the rating of this for example this relay
can have 10 ampere or 250 volts ac this is in Europe Asia majority of those countries using
220 or 240 so 10 times 250 is 2500 watt def can handle if you are in North America it will be
120 125 so 120 times 10 is 1200 watts so this can handle 1200 watt if you are connecting a
DC load just multiply this 30 times 10 that 300 if you are using 30 volts or this is almost the
same so make sure that you understand that total current that can pass through this is
10 amperes so if you overload this you might create fire so make sure to not overload this
let me explain the code I'm not gonna explain everything but briefly this is part of the
library the link will be provided so once you download the library this will be taken care
of let me explain the code I'm not gonna explain everything but briefly this is part of the library
the link will be provided so once you download the library this will be taken care of pen 11 is
for the receiver from the infrared so if your turn 11 is occupied or you want to use it for
other purposes W refers to the white remote if you have otherwise if you're using black
Simo just type this be these are the exactly mu that I have so you will put either B or W
capital and also put single coat around that no double code has explained and if you're using
and if you're using the PCB set PCB equal one and if you're using the bare module just set it equal
zero and if you want to display the code here for example this code which is displayed said
this equal true if you don't want to see the code set as equal false like this with a small little
this portion is for the relay so I'm using pen two here to control the relay the relay will be
connected to pin 2 so you set the pen that you want to use here any digital pen from 2 to 12 in
North window or maybe others or do units that you have but and this on and off this is the
key for example here the 3 is set to turn it on and one to turn it off for that purpose set the
key exact key that you have here in this list exact key that you have it must match there for
example if you want to put channel - for example for this one you must put C H capital with -
so this is the key and and below this you do not change anything this is for white remote
using PCB so when you use this white remote and then PCB these are the values and white
remote without a PCB when you use this one these are the code that I've put here this
is white remote Keys all the keys labels have been explained here and this is for the black
lab remote and then we have black remote with PCB and then we are black remote Keys explained here
upper left okay right and then I put V here for below for these four keys and inside the setup
portal port is here that we said pen mode and a real a pen which is now and two as an output and
also in immediately we set it high high means in this relay this is a low trigger with high
it will go off so that's why we said this high so we turn off the relay at the beginning and
then this loop will continue working for you the portion that is not included with the previous
school that you watched is this portion relay action and so the code I put this relay action
and then I pass the key that is pressed plus minus any number that is so this will come
from all these four portion black remote with PCB black same but without PCB white removed with PCB
white remote without PCB so we are passing the value to the really action method and here the
relay action method will receive the value as a string and here we check if the value
on this is a value that you set here for on and off these are the value we are using down
so we say if that is equal on the leap and low low means energized or turned on and then also
we print the text here and then if it's off we do this one other than that nothing happens here
of this demonstrate turning this light AC bulb on and off using this remote control
or do you know this receiver that is connected to Arduino and relay and this is he bought so
you can control not only ball but anything else motor or anything that you want or maybe DC but
connected to the through the relay so relay can turn it on and off now pressing the plus
the light is on this really has a light but it's not necessary so you can have a relate that does
not have a right so to be the same now turning it off that will go off also I've created the
serial monitor so it can tell you that which key is pressed and what is the status of relay
in case you want to disconnect it from AC and just work here this will tell you and also the
label click so turn on and turn off now this is a PCB version and I'm using the white remote if
you want to use this bare module without that PCB we have to do two things first and the code
we have to select the PCB equal zero and that's it and then upload the code
connected this module now the module is standing not moving AC is now connected
that module is there and it works with that one if I do not select this code TCB equal zero it will
not work make sure because this is not the PCB version without the PCB just pair module so if
you put zero when you use PCB make sure you set this to 1 now this is w it means that's
a white I'm gonna switch it to this black using the black we don't have this plus and
minus that we had here so we can select other keys for example we can select fix to turn it
on and forth to turn it off any of these lets go with a 6 and 4 for that reason for turning
it on I'm gonna put 6 here and for turning it off I'm gonna put 4 upload the code by
default it turns the relay off let me turn it on so I pressed this one and then let me turn
this on turn off turn on so it perfectly works now to use the PCB module the same thing so we
have to make sure that we set one here for PCB uploaded connect the PCB now PCB modulus and
salt the code is uploaded I'm going to press X it's working with PCB now for turning it off
now I'm gonna show you how can you how we can use your own remote to control this a few light
so first we have to capture the code for this remote in order to display the code we display
could we set it equal true this will display the code here for us that's the first thing and then
let's capture for example in this case I want to press 3 to turn on the light and press 1
to turn it off I'm pressing the 3 it so it shows unknown but it's okay so make sure that you press
it two or three times and then and you have to get consistent value so that's all of them are
ending with 9f that's correct I'm gonna just double click and copy it ctrl C I'm pressing
the 3 it so it shows unknown but it's okay so make sure that you press it two or three times
and then and you have to get consistent value so that's all of them are ending with 9f that's
correct I'm gonna just double click and copy it ctrl C and then this is I'm using white PCB go
with this one and find that digit 3 here and replace it and keep the 0x now I'm pressing 1
to turn off the right and then capture the code force that's one you see 20 DF double click copy
and then come here for the one this is done now after that turn on we have to now set 3 here to
turn on and tell our program and forced to turn off oh sorry 1 3 to turn on and want to turn off
this is true I'm using I've changed the code for the white remote make sure to set this to
W and because I'm using because I'm using this PCB make sure the PCB is equal 1 so W refers to
this code that we changed white remote because we were initially using this white so I'm just
replacing it and after that upload the code now I'm using this remote pressing three the light is
on and pressing one the light is off three light on one light off there see me you can do for any
other remote that you have thanks for watching this was how to use your own remote or any other
remote to turn on and off a light using Arduino if you like this video please thumbs up and also
please subscribe so you can get updates of my upcoming videos in upcoming videos in my others
video I'm gonna use this remote to control multiple relays channels to control multiple
items and also I will create another video that using this remote you can control this
servo servos Direction left-right and also stop it and I will have other cool related videos with
this so you can control the direction of a motor speed of the DC motor and stepper motor as well
you