Hi! welcome to our Luna tutorial from Robojax. in this video we are going to see how we can
decode the keys for this server and black remote that us that are sold on eBay using
this infrared receiver an Arduino for example when one key is pressed it will tell you which
key have been pressed I will also show you how you can use your own remote for any TV another
prayer that you have using Arduino to control and devices or turn on and off something using
Arduino with any remote that you have and we will see how we can learn this you can get the
code for this project by clicking on the link at the description below which will take you
to robojax.com/learn/arduino let's get started with this
and this video are going to see how we can use these two remote control and detect them I will
also show you how you can use your own remote for any TV another prayer that you have using
or tweener to control and devices or turn on and off something using Arduino with any remote that
you have that link will be provided for the library but for this one you can use either
this actual small module like that bear module I or me to use as a PCB it does not matter that
these remotes or majority of the codes are the same but because it has more keys just
have 21 and this has 17 keys for that reason I've written code so you just type or select the type
as a B for black or W for white and all the code will work for you or sold on eBay both will come
with either with this I've bent this but with this receiver or you will get this receiver on
a PCB decoding very so whatever this decodes is different or receives done this so just receive
one thing of the same remote and this received the other thing for that reason I have written
the code to make up for those difference and once you receive your package whatever it is
death or this black or this white it should just work fine so we are connecting it to
Arduino and the result will be displayed on the serial monitor some of the kits that is
salt also they give you this infrared transmitter so you can send signal and detect it with this so
this one has written on it vs 183 8b and this module has also written on it vs 183 it be as
you can see the legibility of these two very significantly angle so you can read it better
you see on the left side this PCB seems to be very hardly not eligible as the one that
is on the right but regardless both of them works perfectly fine and the beauty of this
PCB is that when it detects or receives could this light blink which is very good it helps
us understand when the code is received as a datasheet some manufacturers label it as Tier
one eight three eight and in terms of voltage operating voltage two point seven two five point
five volts receiving distance ten to 15 meter this is very long and quiescent current when
there is no signal we are getting typically 0.8 or the maximum of one point 5 milliamperes and
here they've explained the frequency which is 38 kilohertz how the waveforms are outputted from
this device and this is the angle of operation 70 degrees and the distance I they show a 15
meter and the input frequency here again the transmitter must send the 3 8 kilohertz forget it
let me explain now the wiring so you can either use this as a module or use this module without
the PCB in both cases are the same if I hold this like this this is the VCC this is the ground and
that is the signal which will be connected to pen 11 see here this one says negative said the right
one is connected to the ground the middle one is connected to 5 volts on Arduino and the last one
which is labeled as s the signal it's connected to pin 11 to DC see and then ground and this is
for the signal which will go to 1011 make sure that you understand that this is a flat side and
this is the side that you can see on the picture and the signal is on this side as shown here
now let me explain the code when you solve the library this is part of the library receive pen
11 so we set the pan 11 or whatever pen that you want to use in my case I used 11 and then the type
here you type either W with capital or beef or black W for white and it must be inside single
quote double quote will not work make sure to follow that because its character and car type you
put single code and then PCB and if you're using this one you put PCB equal 1 and if you are using
this module just put equal zero and then we are initializing the and we're creating an instance of
this class with passing the PC input pen for the receiver and below this line except these three
you do not change unless your remote control is totally different otherwise for these two remote
control it works fine and I've created one array calls called white remote PCB so this is the code
for the white remote when you are using PCB module because this PCB module reset one way and this
reads it the other way so these are the code for that for channel - charger all the code for that
for all the keys and then we have another array of type integer here it says white remote this is
without PCB and this array will be used when this module is else you don't have to worry it will be
taken care of automatically and after that we define the keys for the white remote so these
are the keys when the code is detected we print this on the screen telling what key of impressed
and this is all black remote these are the values for this black remote when without PCB and this
is a black remote and we have facilitate the end these are the codes for the when you use PCB and
these are the black remote key name or labels and this is the result when the could result this is
a instance of this class inside the setup we have 9600 but when I press a monitor here this is very
important that it must match 9600 baud otherwise you will not be able to read the text and this is
just a text on the screen I our receive enable IRI pen so this initializes up an 11-2 start
receiving inside the loop this is very simple here it says I are receive dot decode and we
pass the result to it and here we get the result resolved dot value is our result so we pass it to
Robo Jack's validate code that I've written which is below I'm gonna explain it next and then we are
resumed this just resumes the loop waiting hundred milliseconds continues in case if you want to read
the actual code that is sent by the remote just remove this make it uncomment and it will print
the code for you on the serial monitor otherwise this will be just a decoded code like ch2 one or
whatever key of stress will be displayed now that mixer in this code when you pass the result it
comes to this function and we call it CD the code that you pass the decoded code so CD or code this
integer found is an internal variable that I use to validate the code found here we check if type
is equal equal these two equal means comparison or comparing so equal capital W and PCB not equal
true when you set it equal zero that means not equal true so we check if it's not PCB and it's
white then this goes from here to here will run so this this is a loop that runs and here it gets the
array of white remote without the PCB and checks it and if the code that user entered is equal the
user entered is equal this value of array whether I ever want to 3 up to all those numbers and then
we press the key press and from here we get the text white remote key so the key name will be
printed and we also said this found equal 1 so later on will be used otherwise if that type is
equal W and this 2 and % means and so this must be true and this must be true we just put PCB I
didn't put any equal sign because it's a Boolean we can use that way I could I could use equal
equal 1 which is extra so this would work but I just bought a PCB which means if it's true this
must be true and this must be true if that is true then we run this one which has PCB and else have
otherwise if the black one if you use a black one then again if with a PCB this code will run else
which means all the possibilities are eliminated so then it must be without the PCB would be this
module then this code will run when that finishes here is the found will be used the found variable
we say F found is not true that means not true then we check for something when you press a key
continuously you get ffff so we say if it's not equal this value of hex integer then we say key
unknown because it's not found and it's not this then weakly unknown the job of this F condition
is also to eliminate this F F so you will not see it on the screen at all and if you want to
do let's say if okay is pressed and you want to do something or this arrow on the right side whatever
just for simplicity let's save ok yes press this for black key this is for the checking
the black key remote so here we say F this value is equal inside the double quote put okay
here we can set a pen hi I'm gonna say pen 9 hi so this will just turn a send
signal to pen 9 of death Arduino and it could be a relay it could be model it
could be light whatever you want you can do the control like that and you
can put multiple conditions for each key you can do different thing here
once installed arrive ready you can go to file examples and then you should see IR remote then
v demo select this one which is this code make sure that this has been 11 if you're connecting
another pen just change it to that pan that you are using and then open the serial monitor now
this is a serial monitor I'm just pressing a key here so this is the actual key that is coming from
the keyboard the FF is as a result of continuous press let's say I'm pressing 8 you see this is all
FF initially at the beginning it receives the code and after that it just turns FF see I press it's
only one time that's the code and another time that's a code but if I press it continuously I
get that FF same thing with this one if I press it continuously I get this value and if I press just
once this is a value and that was a moment that continued so this device received continuously
the signal and as soon as it gets the signal after that if the same signal is received it just prints
out there's ffff for that reason I've put the code in place to remove this and only prenta
key that is known or the key is unknown you will get unknown value saying that LG remote this is
for TV I press volume down as you can see this is actual code but if I continuously press it I will
get FFF that is from the decoder so I plus 5 those are the values favorite so we can read any remotes
code here and then decode it and based on that you can turn on/off something with this remote
using Arduino if you want to use any remote that you have and by pressing a key do something with
Arduino you can just modify this code that I have read the code the way that I shown you and then
put them here accordingly that just 0exif at the beginning and the code that you read just put it
here and put that code reference for yourself and that the code that you have and put the labels for
each key and then take some action based on the key using Arduino now I'm demonstrating have said
this to white to W and then PC be equal one and this is the PCB version of the code so this is
the PCB version of the code and then let me if I press CH plus we should get this code so this
is now also printing the code so this is the code that just printed and also it rented CH
for this double arrow to this side we are getting this B one B for the plus we are getting that one
and so forth so I've enabled this to display the code if I just comment this out but we getting
the key that is pressed sometimes it gives you error just due to the quality of these keys
now I've said this to W which is white and PCB equals zero because I'm not using PCB I'm using
the other module and I have to hold it with my finger again in order to eliminate any false
reading or noise equal 100 plus 2 6 left and then channel so if you are using it make sure to
solder it or have very tight connection because this DuPont wire that I'm using this the wire
for this pens are very thin and it's loose as you can see it's reading very well this to be
for the black I'm testing the black and also PCB equals 0 because PCB is not used as you can see
because this is very loose with a connector we are getting some of those values but if I hold
it tight we will get the right value left arrow down I'm pressing ok so 5 sometimes you will get
some error due to the key quality but generally it works very well now I have set the type to
black and a PCB called 1 because I'm using PCB not as bare module so I press ok and press ok
right arrow down arrow left arrow any of this number that I print press I told display from
time to time you might get error due to the quality of these keys or some other noise
thank you for watching this was how to decode the code for these keys of these two types of
remote please subscribe so you can get updates of my upcoming videos and also follow us on
our Facebook the link for the Facebook is at the bottom of the description link if
you learned something from this video please don't forget to thumb up if you
have comment or questions please post at the description below I try to answer all reply
you