hi welcome to an Arduino tutorial from Robojax in this video I'm going to show you how you can
control a DC motor using infrared remote and infrared receiver with Arduino using l293d to
rotate it right like this when I press it it rotates now right stop it and then rotate it
left I will show you how to use the sulfur remote black remote the receiver with PCB and a receiver
without PCB you can get the code for this project by clicking at the link of the description below
which will take you to robojax.com/learn/arduino let's get started with this
in this video I'm going to show you how you can control a DC motor a tiny DC motor using l293d
chip with infrared and Arduino and I'm going to demonstrate these two types of remotes I have
separate video explaining how to receive signal from these two remote control with the PCB version
or without the PCB version of this 18:38 receiver an Arduino so you have to watch that video make
sure that when you press these keys you receive the signal on the screen make sure that you are
able to use whichever the mode you have either you have a black or the silver one or if you are
having this PCB version or without the PCB version make sure that the undercoat download the library
and it should be able to display that response from the key that you press on the set serial
monitor then I have another video explaining this l293d chip make sure that you are able to control
a motors using this on what Arduino after that then come and use this combined code that I have
provided and for sure it will work and you're able to control the motors using these remote control
now let me explain the wiring for this chip the first thing is that pin 16 goes to 5 volts and
here which I'm going to connect this portion to all the window and here it should spend
16 to VCC 1 that is the 5 volts pen 4 & 5 are connected together both of them to ground and
help and then fourth is connected to pin 5 and both of them are connected to ground so this
is my common ground here we have for the motors I have four diets here I know of two diets are
connected so one day I disconnected from ground and cathode of death is connected to anode and
this is connected to VCC - it voltage for the models so the one pair and then I have another
pair so two pairs from ground and not cathode of this 200 of this one and this is connected
to the positive now let's check here so I have one diode here a node and that's cathode and
this is a node that is cathode here the anode of both of these are connected to ground and
now look this one which comes and then anode and cathode goes here this anode and then cathode of
this one is coming here to the end of this both of these are together from here we will connect
it to the main power supply that 12 volts nine volts whatever is a power supply for
the murders so this goes to the power supply of the model and this one goes to five volts
of Arduino I will remove this for now 10 3 and pin 6 or connection between other than Cassatt
of $1 and then 3 is connected between the other one doesn't matter which one is which so I'm
connecting pin 3 to the middle of this one diode and the other diode that are coming together and
here pantry the suspend three one two three and I'm connecting it and here between these two dice
and he'll have connected pen six to the middle of these two diodes so this diet is coming here
the castle of deathbed and a note of this diode that's connected to pin six now here is a murder
for the murder I have two wires the wire for the model will go exactly between and cathode of one
group which is here and the anode and cathode of the other one which is just blue this is exactly
the same as if we say pen three is connected to the murder and we can say pen sex is connected to
the motor so pen three blue is connected to the one wire of the motor and then six is connected
to the other one because the direction of rotation of this motor can be switched doesn't matter which
one is which but if you have some preference just which should remove this and correctly the other
way from pen it that's coming to the pin one that's enabled that enables this portion and
this version both side so when it is this gray wire here I'm going to connect it to pin one
- and seven of this chip I've arranged it such that then two will be connected to
pin to hold we know past seven we connected to plus seven you know this is connected to
pin seven the white and I'm gonna correct over here - pin 7 and that pin 8 and 7 is here this
is connected to the VCC to 5 volts this portion and this line and this line is connected to the
ground of Arduino I've connected this this wire to 9 volts of external power and v to
the ground ground is connected to the ground which is connected where this yellow to the
ground of Arduino if you are using this PCB the signal goes here this goes to pin 11 the
middle goes to 5 Falls and then here it says - this goes to the ground if we are using this
bare module here or the pants VCC from the this side VCC ground is the middle one and then this
first open 11 which is the signal connected the signal to pen 11 ground if I've been corrected
here VCC is connected here for both of this PCB module on without the PCB the receiver
let me now explain the code I've explained it in a separate video that I mentioned so you have to
watch that here I'm not gonna explain it the only thing that is concerned in this video is
black remote just type black inside a single code and if you're using white remote just type capital
y and double also if you're using this module or that I called SPC be so PC be equal zero if you
are using this one and if you are using this PCB set this equal one this false are true display
is to display the code here if you this is to display the code here if you want to know the
code set this equal T or UE true we have three commands here right left stop if your Forex for
the right we have to know which command or which key are we are using and for example this is for
the black remote capital B so right arrow inside the double code left arrow inside the double
quote okay this must match the code that is the label of the remote here these are the label for
the remote and it must match otherwise it will not work after this you do not change anything
you just go and read it so this is for the black limited PCB these are the codes these are the hash
code this is a voice remote codes for decoding purpose this is the white remote key these are
the labels for this remote I've put them in three because each row has three keys and this is for
the black remote the code for the black remote black remote with PCP when you are using a PC
V version the code will change and these are the black remote labels and these are the labels that
we need to know this is apt left okay right and then down we have four keys here and I put them
inside the double coat and the key that you are selecting to control it must match so this is the
way there so so this key that you're using mass match death otherwise that will not work p1 a is
for the for the DC motor we set 10 to and pinpoint 7 these are the two pans so this is for 22 and 27
and neither the input that is coming from Arduino and planned it if enabled 1 2 that is 4 will be
connected to pin 8 so if you are using the pen for other purpose changes accordingly between 2 to 13
and 10 11 is here for the receiver as well make sure to set this 11 if you are using different
and they said that said that accordingly so this portion is for the motors and this portion this is
for the receiver inside the loop we receive we check if the code result is true so this means
F true then we do all of this so see what we do we save the display code serial so first if we
said that is fully code to display the code for us then we planted a hex value and also we say
Robo jacks validate code and we passed a result dot value and then infrared receive resume and
we wait 500 millisecond and the loop continues this portion is done I explained a validate code
and my other video done in differences this was a relay action or some kind of action here I put
that motor action this is the line which passes a value for the remote this is the value that is
printed a screen also we are passing it this is when we have white remote with PCB white remote
this is when we have white remote without PCB white remote and PCB this is a black remote and
PCB and else this means black remote and not PCB and all of those we just pass motor action and we
pass this value so the motor action will take the value for the remote now let's go for this
and this is a motor action and we see we check it here if we say that is the value that we pass is
equal the right this right and left and stop or the values that have been defined here right left
and stop so we say if the value is equal right we say l293d or mean right and one mean enable
and for the left we just call the same function left and then one mean enable and if the value is
equal stop this doesn't matter right or left but here is the important part zero mean stop and here
l293d that I've written it receives two parameter a character and then zero or one and the character
arrives here we call it the other direction and in a enable the value the other value that's zero
or one we call it enable en and here we check if dir or the direction values this is double equal
sign which means comparison left then here's what we do then we say if enable is there we just say
Motors stopped off and if the enable is not there we can we say motor is rotating and then we enable
the pan so this has been to enable mean if it's one it will be enabled if it's zero it will not
be enabled and then we send pen one a and pen to a one is high the other one is low when we have
this equal right then here the difference is this will be high and low and here will be low
and high so this will change the direction of the motor and automatically if enable is equal
zero the mothers left or right the Enable will pass here and both keys and the motor will stop
let me now demonstrate it I'm using the black remote to control the DC motor and on the sketch
you have to set the type of remote b4 black as it has been explained in my original video and
PCBs equal one because this is now PCB and false display is set to false I'm using this right arrow
key further so for this controlling remote we have three commands for the right for the left and four
stop so we have to have three different commands in order to control motor to rotate right left
and stop so when it will be counter clockwise or clockwise so I just use right and left and this
remote has labels as right I'm using this right arrow to move the motor to the right or clockwise
and this goes counterclockwise for the left and then there is okay button which I have filled
this up inside the double quotation so these are very important the black and white is also single
quotation and then PCB is equal one because I'm using PCB I'm gonna also test this one without
PCB and press it to the right counterclockwise rotating stop it and then clockwise I've set
these two different IDs so you can see the change in colors to tell you which direction is rotating
you can directly go to the other direction or just stop and then go to the next direction
for this silver remote we can use these labels that have defined it inside the code in the
original video so either we can use this this or any of this that you want for example we can use
plus minus and equal so this one whichever you prefer let's go for the channel channel plus to
the right direction to One Direction channel - to the other direction and CH so here they have
been defined exactly here CH capital CH capital CH capital CH you the plus/minus on the method
one which is CH it doesn't have anything so you have to define it first so this is white remote
or salvor so I put W because we are using PCB so that's VC B and here that's what CH +
so we are defining the key that is there so and TCB is equal one just uploaded so pressing it
to the right and then pressing the middle one to stop pressing the left directly go to the right
now I've removed the PCB module just the bare 18:38 module here with a solver the
only difference at this time is that I said PCB equals zero that's just just it I think
this channel + th + stop and then channel - so clockwise you can go directly clockwise or stop
for the black remote I've set type capital B and PCB equals
zero because this is not PCB and PCBs here how with a black remote
this key that arrow to the right what do you think stopping go to the left
stopping thank you for watching this was how to use these two remote control with Arduino
to control the DC motors change the direction and stop it if you learn something from this
video and if you liked it please thumbs up and also subscribe so you can get updates
of my upcoming video ring for our Facebook pages also at the bottom of the description