This is that seven of the final project and now in this step, we are going to add another component
to the application and this is the infrared remote control.
But we have this component.
We are going to be able to add a lot of interactiveness to the application.
And in the following steps, we're going to map different buttons to different functionalities.
But first, what we're going to do in this step right now is to initialize the infrared remote controller
with the infrared remote library and also to map so to create some defines the buttons we are going
to use.
So first, let's include our remote dot h.
So I am going to write the code here for the version three because I have installed the version three
of the remote library.
If you are using version two, if you are using the simulation, then please just modify the few lines
that are specific to version three to listen to and it will work the same.
And also at the end, after the last tape, I'm going to one more video to show you the application,
working with version two on the Tinker CAD Simulation.
All right.
So let's get started with this.
I'm going to add so let's add it here.
Define I receive being, which has been number five for me.
So library define a pin.
And then for version three, we just go to the set and now you can see the code starts to be a little
bit longer.
So in the setup, let's say so let's initialize cell density.
And just after that I see where that begin with AIPA.
Receive.
We initialize the infrared receiver component and then in the loop, so we have to decide, do we want
to get the data from the infrared remote controller when the application is so?
Only if the application is locked or only if the application is not locked all at any time, not depending
on if the application is locked up, not locked in here.
What I'm going to do, I'm going to choose to receive the data at any time.
So any time we press on a button, we will be able to execute some action.
But then maybe on the function that will be called, we can add some condition.
And so the action might be different, but when the application is locked, are not locked.
But at the source of the data, we want to read the data at any time.
So if I mean to put it here.
I receiver that decode, and then let's do a receiver that resumes so we don't forget this and then
let's get to come on as a long.
So I previously used it, which is fine for Division three.
I'm going to use long.
So it's the same for version two and three.
And that's not really a problem here at receiver that decoded data dot com.
We get to know we will be able to do our switch.
But before we do that, I'm going to say this print, Ellan, come in because we need to map the data
we receive so the command we receive with some buttons.
So what I'm going to do now is I'm going to bring the command, create some defense.
And after that comment, this Saillard print Allen line and let's go to the top.
So we have our defines for the pins and then the distance.
Let's add some other defense here.
For the buttons we need.
So first I'm going to need a button.
I'm going to need a button plate, so I'm not going to put the value right now.
Define AIPA, but let's just go, please, a few times.
OK.
So we need to play, but we need the off button, we need the UCU button, we need also the up and down
button and that's it for the project.
So instead of mapping all the buttons we need for each step when we need them, I'm just going to map
them all together.
And the beginning, that's a little bit simpler.
Let's add a command here I r button mapping and let's command this for now.
So eight commands, OK?
And let's run the code.
So far we have initialized the infrared remote library and in the set which is here, so we set up the
receiver and in the loop we get the comments that we send with the controller and we print them.
So let's print them and not weave those defangs.
So I am going first to verify the code and just see it as final project stepmoms seven.
Get down compelling some note here that the upload code, and actually it's better if I connect my outfit
both back to old OK and upload.
So let's open the sale monitor and then I'm going to point the remote control out to the remote receiver
and let's first press on the play better.
I get 64, so I'm going to put sixty four here and then the off button.
Sixty nine, sixty nine in the EKU, but.
It gives us 25.
So as you can see many times on the bottom, just to make sure that if I get some wrong data, I can
see I get twenty five minutes.
So if I get the wrong data, I just don't take it into account.
Now the up button.
But bottom line.
And down Britain is a much.
But the same window down button is.
So I use those buttons, you can just use any other buttons you want for your point, that's now.
So what I'm going to do, I'm going to remove the comments here.
So now we have the defense and it's a line here just.
Make it nicer and more relatable.
OK.
So now let's see you again.
And now we are ready to use that remote control in our code, we have mapped debate and now all we need
to do is do a switch to check which command we have received and then do some action depending on the
command.