WEBVTT

00:00.180 --> 00:04.560
So no doubt you can read the data from your infrared remote controller.

00:04.890 --> 00:12.360
Now it's time to map the different button, OK, because for every different infrared remote control,

00:12.390 --> 00:15.180
you will get different data for different buttons.

00:15.540 --> 00:22.490
So, no, this program is nice to get what is the code or what is the number you will get for each button

00:22.500 --> 00:23.670
of your control.

00:24.060 --> 00:29.550
But then, for example, if you want to do an action, when you press on the play button and action

00:29.550 --> 00:34.350
when you press on the button, number one, then you need to keep that value inside your program.

00:34.540 --> 00:36.870
So we are going to create some defiance here.

00:37.020 --> 00:42.750
For example, define OK, we are going to create some definably to commence that fungo.

00:43.170 --> 00:50.250
Some define four different buttons of the controller and to get what buttons will you have to use that

00:50.250 --> 00:50.560
code.

00:50.580 --> 00:58.500
So either with addition to our version three to just print the data, I'm going to add to the codes

00:58.500 --> 01:02.940
to make sure the board is connected and then append a statement.

01:03.450 --> 01:12.840
And let's say I want to map the number zero, like click it on zero and I get so I had to come in here,

01:12.840 --> 01:16.470
which is 20 to going to do a version three.

01:16.470 --> 01:25.800
And in addition to we think, OK, so define I r let's say I have a button and then zero and this is

01:25.800 --> 01:26.380
twenty two.

01:26.970 --> 01:28.370
OK, so not in my code.

01:28.500 --> 01:33.390
Whenever I want to check, if I have pressed on the button zero I just use that define.

01:33.540 --> 01:35.480
I don't need to remember the twenty two.

01:35.490 --> 01:39.720
It is set once forever for this specific remote controller.

01:41.100 --> 01:44.860
Now, let's press the button one, I get 12.

01:45.540 --> 01:46.670
So let's do this.

01:48.610 --> 01:55.270
One hundred twelve and let's press the button to make a test and get 24.

01:58.720 --> 01:59.850
OK, 24.

02:00.040 --> 02:07.150
And then let's press the button play, for example, play, oppose, so play, oppose and get 64.

02:12.510 --> 02:18.150
I have chosen to play both indices sixty.

02:18.840 --> 02:22.030
So, of course, the values are going to be different for you.

02:22.120 --> 02:24.040
OK, maybe you will get the same.

02:24.100 --> 02:26.180
I don't know, maybe maybe different values.

02:26.190 --> 02:30.270
You have to map by yourself the different numbers with the different.

02:30.480 --> 02:37.500
But another thing is that the buttons you see on your controller, for example, zero one, two, three

02:37.500 --> 02:41.630
play, but we're of volume, etc. They don't mean anything, OK?

02:41.700 --> 02:45.780
Each button just has a number and then you do whatever you want with this button.

02:46.050 --> 02:51.510
So I could say that I can play something when I press on the button five and I can use the button play

02:51.690 --> 02:53.600
to print the number nine, for example.

02:53.700 --> 02:57.870
OK, but of course we are trying to make sense of the button.

02:57.880 --> 03:03.030
OK, we are going to map the button and then use them in the code so it makes sense.

03:03.360 --> 03:03.800
OK, all right.

03:03.810 --> 03:09.210
But what you have to know is that all the buttons you see on your remote controller is just a different

03:09.210 --> 03:10.380
number for each button.

03:10.460 --> 03:12.590
OK, and then you do whatever you want with them.

03:12.750 --> 03:15.150
So in the code now if we want to use them.

03:15.330 --> 03:16.860
So I'm going to keep the same set up.

03:17.160 --> 03:20.040
I'm going to say I'm going to keep the same loop.

03:20.160 --> 03:30.960
If I have received the code, I receive a resume and then let's actually connect those lines.

03:33.530 --> 03:36.410
And let's do, for example, if.

03:37.690 --> 03:38.650
So this.

03:40.620 --> 03:45.180
If command is equal with two equal to, for example, button zero.

03:47.800 --> 04:00.430
And then we can do, for example, sale, let's bring in button zero was priced, then we can do else

04:00.570 --> 04:02.620
if and then the same.

04:05.650 --> 04:08.050
Is equal to Britain one.

04:10.230 --> 04:18.780
We do an action for childhood print, Ellen Burton, one was priced.

04:21.110 --> 04:29.410
So actually, instead of writing this every time, what I can do is create first it come in from the

04:29.420 --> 04:32.140
Bible is equal to all of that.

04:32.150 --> 04:33.410
So we just need to write.

04:34.950 --> 04:41.060
Come in here, we are going to use the variable that we create here, which is the command we receive,

04:41.070 --> 04:47.580
so we don't need to get that every time you come on, is this that we have defined, we do something

04:47.610 --> 04:47.990
else.

04:48.000 --> 04:56.130
If these we do this and let's do another one as if command is equal to the button play.

04:58.900 --> 05:05.650
Let's see, Selders, Brent, Ellen play was raised.

05:07.500 --> 05:17.060
And let's do as well, let's say we don't want the button actually hits button two zero one and two.

05:18.340 --> 05:27.890
So if we just want the button zero one in play and then let's see, sailboat's L.N., please press another.

05:28.870 --> 05:35.160
But just just like, OK, so this way if and if else, if else.

05:35.290 --> 05:40.900
And you can add as many as if you want, you can just do an action depending on what button you have

05:40.900 --> 05:41.290
pressed.

05:41.810 --> 05:43.180
Now let's put this.

05:45.440 --> 05:51.020
And we have an error because I have forgotten the semicolon here.

05:54.260 --> 06:00.290
And now let's see what we have in the same minute, I'm going to clear the output, let's press on the

06:00.290 --> 06:01.130
button zero.

06:01.340 --> 06:09.230
Button zero was priced at the press button one button, one was pressed button play that and you can

06:09.230 --> 06:10.770
see here button play with price.

06:10.790 --> 06:17.540
I press many times and then let's price, for example, the button, move forward, press another button,

06:17.540 --> 06:23.900
so please press another and any other button that a price that is not zero one or play.

06:23.900 --> 06:32.180
We get this message so you have a way to first create some defense with the value you get.

06:32.930 --> 06:40.160
And then we if as you've structure, you can do an action for each button that was pressed and ready

06:40.160 --> 06:41.030
for this in the next.

06:41.030 --> 06:43.730
Listen, I'm going to show you a different way of doing this.

06:44.030 --> 06:45.740
We what we call switch.

06:46.840 --> 06:49.720
All right, hand back to Tinker, can't just show you.

06:49.750 --> 06:53.400
So this is the version two of the library.

06:53.740 --> 06:57.580
So if you use this on the original Tinker Cat, this is how you can do this.

06:57.580 --> 07:00.880
So I'm going to start the simulation or start the program.

07:01.210 --> 07:01.750
Right.

07:01.750 --> 07:09.440
And let's open the ceremony to let's clear let's press on zero zero gives us this volume.

07:10.150 --> 07:10.950
So what I can do.

07:11.200 --> 07:12.240
Let's stop.

07:12.880 --> 07:17.380
OK, I'm going to so you have to stop the simulation here to write some code.

07:17.980 --> 07:28.720
So let's I'm going to define a button zero and then so to write an exodus you have to start with zero

07:29.230 --> 07:29.860
X..

07:30.610 --> 07:39.020
So this is F the three zero C, this is this is the representation of hexadecimal.

07:39.040 --> 07:42.910
No, you have to write zero X first and then the number.

07:43.180 --> 07:43.600
All right.

07:43.870 --> 07:45.260
Don't forget the zero X.

07:45.670 --> 07:47.060
So here I have four.

07:47.080 --> 07:50.810
The button zero you can do for every button you need.

07:50.940 --> 07:56.590
OK, if you want, you can map all the buttons of your remote so you already have everything.

07:56.920 --> 07:59.020
Or you can just make them as you need them.
