So no doubt you can read the data from your infrared remote controller.
Now it's time to map the different button, OK, because for every different infrared remote control,
you will get different data for different buttons.
So, no, this program is nice to get what is the code or what is the number you will get for each button
of your control.
But then, for example, if you want to do an action, when you press on the play button and action
when you press on the button, number one, then you need to keep that value inside your program.
So we are going to create some defiance here.
For example, define OK, we are going to create some definably to commence that fungo.
Some define four different buttons of the controller and to get what buttons will you have to use that
code.
So either with addition to our version three to just print the data, I'm going to add to the codes
to make sure the board is connected and then append a statement.
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,
which is 20 to going to do a version three.
And in addition to we think, OK, so define I r let's say I have a button and then zero and this is
twenty two.
OK, so not in my code.
Whenever I want to check, if I have pressed on the button zero I just use that define.
I don't need to remember the twenty two.
It is set once forever for this specific remote controller.
Now, let's press the button one, I get 12.
So let's do this.
One hundred twelve and let's press the button to make a test and get 24.
OK, 24.
And then let's press the button play, for example, play, oppose, so play, oppose and get 64.
I have chosen to play both indices sixty.
So, of course, the values are going to be different for you.
OK, maybe you will get the same.
I don't know, maybe maybe different values.
You have to map by yourself the different numbers with the different.
But another thing is that the buttons you see on your controller, for example, zero one, two, three
play, but we're of volume, etc. They don't mean anything, OK?
Each button just has a number and then you do whatever you want with this button.
So I could say that I can play something when I press on the button five and I can use the button play
to print the number nine, for example.
OK, but of course we are trying to make sense of the button.
OK, we are going to map the button and then use them in the code so it makes sense.
OK, all right.
But what you have to know is that all the buttons you see on your remote controller is just a different
number for each button.
OK, and then you do whatever you want with them.
So in the code now if we want to use them.
So I'm going to keep the same set up.
I'm going to say I'm going to keep the same loop.
If I have received the code, I receive a resume and then let's actually connect those lines.
And let's do, for example, if.
So this.
If command is equal with two equal to, for example, button zero.
And then we can do, for example, sale, let's bring in button zero was priced, then we can do else
if and then the same.
Is equal to Britain one.
We do an action for childhood print, Ellen Burton, one was priced.
So actually, instead of writing this every time, what I can do is create first it come in from the
Bible is equal to all of that.
So we just need to write.
Come in here, we are going to use the variable that we create here, which is the command we receive,
so we don't need to get that every time you come on, is this that we have defined, we do something
else.
If these we do this and let's do another one as if command is equal to the button play.
Let's see, Selders, Brent, Ellen play was raised.
And let's do as well, let's say we don't want the button actually hits button two zero one and two.
So if we just want the button zero one in play and then let's see, sailboat's L.N., please press another.
But just just like, OK, so this way if and if else, if else.
And you can add as many as if you want, you can just do an action depending on what button you have
pressed.
Now let's put this.
And we have an error because I have forgotten the semicolon here.
And now let's see what we have in the same minute, I'm going to clear the output, let's press on the
button zero.
Button zero was priced at the press button one button, one was pressed button play that and you can
see here button play with price.
I press many times and then let's price, for example, the button, move forward, press another button,
so please press another and any other button that a price that is not zero one or play.
We get this message so you have a way to first create some defense with the value you get.
And then we if as you've structure, you can do an action for each button that was pressed and ready
for this in the next.
Listen, I'm going to show you a different way of doing this.
We what we call switch.
All right, hand back to Tinker, can't just show you.
So this is the version two of the library.
So if you use this on the original Tinker Cat, this is how you can do this.
So I'm going to start the simulation or start the program.
Right.
And let's open the ceremony to let's clear let's press on zero zero gives us this volume.
So what I can do.
Let's stop.
OK, I'm going to so you have to stop the simulation here to write some code.
So let's I'm going to define a button zero and then so to write an exodus you have to start with zero
X..
So this is F the three zero C, this is this is the representation of hexadecimal.
No, you have to write zero X first and then the number.
All right.
Don't forget the zero X.
So here I have four.
The button zero you can do for every button you need.
OK, if you want, you can map all the buttons of your remote so you already have everything.
Or you can just make them as you need them.