WEBVTT

00:00.210 --> 00:06.240
This is the solution of the previous activity where you need to complete this project to create a full

00:06.240 --> 00:07.840
multitask project.

00:07.930 --> 00:15.360
OK, by setting the analogy to write from the potential meter and by borrowing on the three when the

00:15.360 --> 00:16.770
button is pressed.

00:17.220 --> 00:20.070
OK, and what I'm going to do, because here it's activity nine.

00:20.070 --> 00:21.840
So I'm not going to write code on this.

00:21.840 --> 00:29.820
I'm going to write everything, copy everything, and then create a new project and then everything.

00:29.830 --> 00:39.450
So we start on the new project that I am going to compile and save as activity in.

00:41.370 --> 00:49.170
All right, so our first action, which is to change the delay for the blank, for any one, is already

00:49.500 --> 00:49.970
done.

00:50.520 --> 00:58.010
So not what we can do is to do this action, which is to set the energy brightness from the potential.

00:58.800 --> 01:10.650
So the we need to hear the fine energy to in is Ongpin number 11 so we can use the PWI in functionality

01:10.860 --> 01:11.310
on that.

01:11.310 --> 01:16.950
People also here and I'm simply going to rename it as the one thing.

01:17.680 --> 01:21.990
OK, I'm just going to add one little delay.

01:23.120 --> 01:23.810
Let's see.

01:25.110 --> 01:28.110
Anyone one, any one state.

01:30.650 --> 01:32.180
Linda, that is one.

01:33.820 --> 01:35.310
It just to make more sense.

01:37.830 --> 01:46.470
Because we have multiple entities in here and it is one thing, and you are at any one state and one

01:46.470 --> 01:50.100
state, you want also one here.

01:52.810 --> 01:53.830
In and.

01:55.090 --> 01:59.810
OK, let's just come by to see if I have any error, no.

02:01.210 --> 02:06.310
OK, so if you just have one entity, then it's OK not to put a number on it, but here because we have

02:06.310 --> 02:11.800
multiple ones, I just want to make sure that it will not be confusing later.

02:12.670 --> 02:15.430
So we find Eddie to be 11.

02:15.820 --> 02:18.950
This are having to initialize it here.

02:18.970 --> 02:23.740
So queen mode up in output.

02:26.120 --> 02:32.420
And then in the loop, we are going to sit brightness from the potential of this, so we need potentially

02:32.420 --> 02:34.430
to define.

02:37.140 --> 02:43.830
But extreme weather in which she's a tool, OK, we don't need to actually do spin mode because this

02:43.830 --> 02:45.330
is an analog input being.

02:46.660 --> 02:53.070
Right, and then in the loop, so what I'm going to do, I'm simply going to do the action here, OK,

02:53.440 --> 02:55.900
so we have action one.

02:58.760 --> 02:59.510
According to.

03:00.950 --> 03:09.320
And then action three, action three is simply to get the put on shareholder value put on Shimura.

03:10.870 --> 03:14.850
Value is equal to analog radio.

03:14.920 --> 03:17.620
OK, with the lunchmeat a cleaner.

03:20.960 --> 03:22.490
All right, now we can do.

03:24.530 --> 03:26.510
In intensity.

03:27.940 --> 03:29.400
Which will be put on Sumate.

03:31.270 --> 03:33.820
Value divided by four.

03:33.890 --> 03:40.960
OK, if you remember, the value we get from an is between zero and one thousand twenty three and the

03:40.960 --> 03:49.340
value we can give with the analog right function is between zero and two hundred fifty five.

03:49.360 --> 03:51.970
So we need to divide the value by four.

03:53.120 --> 03:58.430
So, Andrew, great to write on PIN number 11 with the W.M. function.

03:59.690 --> 04:03.770
And to deal with intensity.

04:05.740 --> 04:11.590
And that is the action three and here, this will not pose any problem because this is quite fast,

04:11.630 --> 04:16.500
OK, we use an override function, so this will not block the code for too long.

04:16.840 --> 04:19.770
Then we just do an operation and we are going to go, right, OK.

04:19.780 --> 04:22.570
We don't use any delay, though, because we don't use the delay.

04:23.020 --> 04:24.880
We don't need to use that structure.

04:25.240 --> 04:32.650
It does structure is only when you use delay and basically only when you want to wait a certain time

04:32.800 --> 04:35.080
before you do a different action.

04:35.320 --> 04:42.820
So here, if we wanted, for example, to update the energy intensity, but not every time we enter

04:42.820 --> 04:49.180
the loop, but instead, for example, every three hundred milliseconds, what we could do is use this

04:49.180 --> 04:49.800
structure.

04:50.200 --> 04:52.540
But because we want to do it as fast as possible.

04:52.570 --> 04:53.870
Well, that's not a problem.

04:54.580 --> 04:56.590
And now the action for.

04:59.490 --> 05:12.180
Which is simply too poor on the third when we raise the budget, so we need to find a way in which it's

05:12.180 --> 05:15.660
been a 10, I'm going to initialize it here.

05:17.270 --> 05:17.780
Mode.

05:18.650 --> 05:18.950
A.

05:20.620 --> 05:21.810
Three in.

05:25.620 --> 05:26.910
And we also need.

05:28.780 --> 05:29.500
Who define.

05:31.260 --> 05:31.920
Button.

05:33.110 --> 05:41.870
In which he has been number two, the digital pin number two, and also teen mode button pin.

05:43.580 --> 05:44.750
In what?

05:48.040 --> 05:55.390
We have initially been not in the loop, we can do the action, so now what we can do is check if.

05:56.320 --> 05:59.680
Digital read Butterbean.

06:01.810 --> 06:06.010
Is equal to I wish to equal saying.

06:07.810 --> 06:12.220
Then we enter this book of code and we put on so digital.

06:14.160 --> 06:14.720
Right.

06:15.900 --> 06:16.520
Ali.

06:17.680 --> 06:19.090
Three senior.

06:20.460 --> 06:25.950
We've high we report on the 83 and of course, don't forget the elsea.

06:28.440 --> 06:38.280
If the button is not pressed, we need to pull off digital, right, and the thing we need to pull it

06:38.330 --> 06:38.550
off.

06:40.050 --> 06:40.460
All right.

06:40.470 --> 06:41.070
And that's it.

06:41.100 --> 06:48.750
So as you can see, this also doesn't need a delay, OK, because we want to update this as fast as

06:48.750 --> 06:52.300
possible, as fast as we did the data, just as we did here.

06:52.860 --> 07:00.030
So if you wanted to update only every one hundred milliseconds and you would have used a structure like

07:00.030 --> 07:00.390
this.

07:00.840 --> 07:02.720
OK, but we disagree with you.

07:02.730 --> 07:05.800
What I want to show you is that create a multitask program.

07:06.180 --> 07:13.220
You simply need to do all the operations, OK, all the actions you want to function one by one.

07:13.620 --> 07:17.860
Just make sure that no action is blocking the execution.

07:17.880 --> 07:24.390
OK, because here we have four different actions no one is blocking will delay, which means that they

07:24.390 --> 07:27.480
are going to be executed very, very fast.

07:27.850 --> 07:34.080
So because they are executing very, very fast, then it's almost like they are executed at the same

07:34.080 --> 07:34.470
time.

07:34.680 --> 07:37.470
And this is where you have the multitask program.

07:38.480 --> 07:42.590
All right, and now let's applaud that programme to our Adreno.

07:43.940 --> 07:44.330
All right.

07:44.330 --> 07:50.180
And you can see here, so we have our first energy, which blinks every five hundred milliseconds,

07:50.420 --> 07:51.850
let's say, on monitor.

07:52.210 --> 07:53.690
And I can just change it.

07:53.690 --> 07:54.670
Let's say 200.

07:54.680 --> 07:56.060
It blinks much faster.

07:56.450 --> 07:57.860
Let's say three dozen.

07:57.860 --> 08:00.530
It blinks every three seconds.

08:01.960 --> 08:08.510
OK, and we have our second lady here, you can see is already power on it, but because this is from

08:08.510 --> 08:14.320
the bottom shmita, I can increase and decrease the value, as you can see from the bottom me, that

08:15.580 --> 08:20.050
this is happening at the same time as the first lady blink.

08:20.410 --> 08:28.810
And what I can do is from the bottom, I can also power on the third and this and I can do everything

08:28.810 --> 08:29.450
at the same thing.

08:29.520 --> 08:30.310
OK, yeah.

08:30.310 --> 08:37.000
And moving the production meter, I put on the push button, I press the button at the same time you

08:37.000 --> 08:39.490
can see the first lady is still blinking.

08:40.120 --> 08:43.170
So everything is happening at the same time.

08:45.520 --> 08:47.690
All right, so that's the end of this activity.

08:48.190 --> 08:53.710
Now, you should have a better understanding on how to use the time functionalities so you can avoid

08:53.710 --> 09:00.040
using delay in the volume function and you can create as many actions as you want.

09:00.080 --> 09:06.130
OK, you just need to put all the actions in the order you want and then they are going to be executed

09:06.130 --> 09:10.790
so fast, which means that you have created a multitask program.

09:11.170 --> 09:12.090
Congratulations.

09:12.100 --> 09:14.440
That's the great progress you have just made.
