WEBVTT

00:00.180 --> 00:07.590
This is that seven of the final project and now in this step, we are going to add another component

00:07.590 --> 00:11.630
to the application and this is the infrared remote control.

00:11.910 --> 00:12.840
But we have this component.

00:12.850 --> 00:17.240
We are going to be able to add a lot of interactiveness to the application.

00:17.580 --> 00:22.830
And in the following steps, we're going to map different buttons to different functionalities.

00:22.860 --> 00:30.330
But first, what we're going to do in this step right now is to initialize the infrared remote controller

00:30.330 --> 00:37.410
with the infrared remote library and also to map so to create some defines the buttons we are going

00:37.410 --> 00:37.890
to use.

00:38.640 --> 00:44.430
So first, let's include our remote dot h.

00:44.790 --> 00:50.610
So I am going to write the code here for the version three because I have installed the version three

00:50.610 --> 00:52.580
of the remote library.

00:52.980 --> 00:59.490
If you are using version two, if you are using the simulation, then please just modify the few lines

00:59.490 --> 01:02.820
that are specific to version three to listen to and it will work the same.

01:03.180 --> 01:09.120
And also at the end, after the last tape, I'm going to one more video to show you the application,

01:09.120 --> 01:12.690
working with version two on the Tinker CAD Simulation.

01:13.080 --> 01:13.410
All right.

01:13.410 --> 01:14.890
So let's get started with this.

01:14.910 --> 01:17.090
I'm going to add so let's add it here.

01:17.430 --> 01:24.120
Define I receive being, which has been number five for me.

01:25.050 --> 01:27.930
So library define a pin.

01:27.930 --> 01:34.020
And then for version three, we just go to the set and now you can see the code starts to be a little

01:34.020 --> 01:34.750
bit longer.

01:35.190 --> 01:40.140
So in the setup, let's say so let's initialize cell density.

01:40.140 --> 01:47.790
And just after that I see where that begin with AIPA.

01:49.200 --> 01:49.860
Receive.

01:51.480 --> 02:00.480
We initialize the infrared receiver component and then in the loop, so we have to decide, do we want

02:00.480 --> 02:08.040
to get the data from the infrared remote controller when the application is so?

02:08.040 --> 02:16.200
Only if the application is locked or only if the application is not locked all at any time, not depending

02:16.200 --> 02:19.100
on if the application is locked up, not locked in here.

02:19.110 --> 02:24.090
What I'm going to do, I'm going to choose to receive the data at any time.

02:24.630 --> 02:29.460
So any time we press on a button, we will be able to execute some action.

02:29.460 --> 02:34.830
But then maybe on the function that will be called, we can add some condition.

02:35.070 --> 02:39.920
And so the action might be different, but when the application is locked, are not locked.

02:40.230 --> 02:45.030
But at the source of the data, we want to read the data at any time.

02:45.060 --> 02:47.400
So if I mean to put it here.

02:48.810 --> 03:01.720
I receiver that decode, and then let's do a receiver that resumes so we don't forget this and then

03:01.900 --> 03:03.730
let's get to come on as a long.

03:03.730 --> 03:08.890
So I previously used it, which is fine for Division three.

03:08.890 --> 03:09.930
I'm going to use long.

03:10.270 --> 03:12.730
So it's the same for version two and three.

03:12.730 --> 03:23.760
And that's not really a problem here at receiver that decoded data dot com.

03:24.970 --> 03:28.060
We get to know we will be able to do our switch.

03:28.300 --> 03:37.090
But before we do that, I'm going to say this print, Ellan, come in because we need to map the data

03:37.090 --> 03:40.120
we receive so the command we receive with some buttons.

03:40.540 --> 03:44.580
So what I'm going to do now is I'm going to bring the command, create some defense.

03:44.590 --> 03:51.270
And after that comment, this Saillard print Allen line and let's go to the top.

03:51.670 --> 03:57.310
So we have our defines for the pins and then the distance.

03:57.310 --> 03:59.500
Let's add some other defense here.

04:01.510 --> 04:04.250
For the buttons we need.

04:04.480 --> 04:07.720
So first I'm going to need a button.

04:07.750 --> 04:12.880
I'm going to need a button plate, so I'm not going to put the value right now.

04:16.140 --> 04:22.920
Define AIPA, but let's just go, please, a few times.

04:25.570 --> 04:26.100
OK.

04:27.340 --> 04:37.540
So we need to play, but we need the off button, we need the UCU button, we need also the up and down

04:37.540 --> 04:40.110
button and that's it for the project.

04:40.930 --> 04:47.680
So instead of mapping all the buttons we need for each step when we need them, I'm just going to map

04:47.680 --> 04:49.060
them all together.

04:49.060 --> 04:51.370
And the beginning, that's a little bit simpler.

04:52.210 --> 04:59.450
Let's add a command here I r button mapping and let's command this for now.

04:59.920 --> 05:02.620
So eight commands, OK?

05:02.950 --> 05:03.950
And let's run the code.

05:04.010 --> 05:13.870
So far we have initialized the infrared remote library and in the set which is here, so we set up the

05:14.830 --> 05:20.260
receiver and in the loop we get the comments that we send with the controller and we print them.

05:20.530 --> 05:24.550
So let's print them and not weave those defangs.

05:25.060 --> 05:31.060
So I am going first to verify the code and just see it as final project stepmoms seven.

05:33.160 --> 05:44.440
Get down compelling some note here that the upload code, and actually it's better if I connect my outfit

05:44.450 --> 05:48.760
both back to old OK and upload.

05:51.390 --> 06:00.780
So let's open the sale monitor and then I'm going to point the remote control out to the remote receiver

06:00.810 --> 06:04.460
and let's first press on the play better.

06:05.460 --> 06:12.570
I get 64, so I'm going to put sixty four here and then the off button.

06:14.760 --> 06:21.390
Sixty nine, sixty nine in the EKU, but.

06:23.200 --> 06:25.450
It gives us 25.

06:26.960 --> 06:33.830
So as you can see many times on the bottom, just to make sure that if I get some wrong data, I can

06:33.830 --> 06:35.160
see I get twenty five minutes.

06:35.270 --> 06:38.430
So if I get the wrong data, I just don't take it into account.

06:38.810 --> 06:40.390
Now the up button.

06:43.080 --> 06:44.150
But bottom line.

06:45.930 --> 06:48.970
And down Britain is a much.

06:50.090 --> 06:52.580
But the same window down button is.

06:56.770 --> 07:02.700
So I use those buttons, you can just use any other buttons you want for your point, that's now.

07:03.010 --> 07:05.760
So what I'm going to do, I'm going to remove the comments here.

07:06.820 --> 07:10.870
So now we have the defense and it's a line here just.

07:11.830 --> 07:14.350
Make it nicer and more relatable.

07:14.410 --> 07:14.710
OK.

07:16.280 --> 07:17.750
So now let's see you again.

07:19.600 --> 07:26.740
And now we are ready to use that remote control in our code, we have mapped debate and now all we need

07:26.740 --> 07:32.920
to do is do a switch to check which command we have received and then do some action depending on the

07:32.920 --> 07:33.330
command.
