WEBVTT

00:00.210 --> 00:08.700
This is the solution of the previous activity where you have to make the fade in and fade out so we

00:08.700 --> 00:12.180
can actually separate this project into two parts.

00:12.540 --> 00:20.640
First, we need to make sure that we have the index going from zero to 255 and then 255 to zero, and

00:20.640 --> 00:25.090
then we need to set up the idea and use the analog right function.

00:25.410 --> 00:28.520
So I'm going to work first on the two for loops.

00:28.530 --> 00:34.710
We need to do that and make sure we have the correct values using the same monitor for debugging.

00:35.100 --> 00:38.330
And then I'm going to write another great function.

00:38.700 --> 00:42.240
I'm going to remove all of the comments.

00:44.300 --> 00:54.470
And start with the first full loop so far, and then we create an index, it is equal to zero, so we

00:54.470 --> 00:58.430
start at zero and then what is the maximum value we want?

00:58.910 --> 01:01.670
The maximum value we want is 255.

01:01.700 --> 01:07.240
So I is lower are equal than two hundred fifty five.

01:07.670 --> 01:14.940
We could also use a strictly lower than two hundred fifty six and then I placeless.

01:15.430 --> 01:22.550
So the follow up we go from zero to two hundred fifty five increasing by one every time.

01:23.600 --> 01:26.960
OK, that is the first the second for Luke.

01:29.530 --> 01:31.870
So I'd like to get into space.

01:33.050 --> 01:43.430
We're going to start from two hundred fifty five, OK, and we're going to stop at zero, so while I

01:43.670 --> 01:48.430
still greater or equal than zero, we continue.

01:48.440 --> 01:53.090
OK, you can read this as while this is true, we continue.

01:54.110 --> 02:03.730
And then I'm minus minus, which means that we are going to decrements this index every time.

02:04.190 --> 02:09.190
OK, I know the full ups are complete because here you can see we start at zero.

02:09.200 --> 02:15.200
We go to 255 in this one, and then from 255 to zero.

02:16.100 --> 02:22.880
And once we have finished those two follow ups, well, we go out of the void Leupen.

02:22.880 --> 02:26.850
We go in again and we start again at zero.

02:26.870 --> 02:29.630
So there is a continuity with the index here.

02:29.810 --> 02:33.980
I know what I'm going to do is simply print to be sure that we have the correct values.

02:34.310 --> 02:36.700
So surreal that begin.

02:37.590 --> 02:44.690
OK, don't forget that we have nine thousand six hundred but right in the center function and here I'm

02:44.690 --> 02:46.220
going to do say I've got.

02:47.290 --> 02:49.930
Print and then we've I.

02:51.300 --> 02:54.660
And also, there are those prints, Ellen.

02:56.570 --> 03:04.710
We are as well, and as you can see here, we use the same name because this is a different scope.

03:04.730 --> 03:09.020
OK, here the eye viable is local to the folk.

03:09.380 --> 03:17.270
So basically it is contained between those two curly brackets looking this scope and this is in that

03:17.480 --> 03:17.940
scope.

03:17.960 --> 03:21.860
OK, so two different scopes and know what I'm going to do.

03:21.870 --> 03:25.710
I'm going to add delay five.

03:25.910 --> 03:33.050
OK, I'm going to add the delay because if we don't add the delay, it will print very, very fast and

03:33.050 --> 03:34.780
it's not that reliable.

03:35.420 --> 03:37.400
And well, let's try this first round.

03:37.420 --> 03:40.790
So I'm going to compile the code as.

03:42.580 --> 03:44.080
Activity to.

03:46.210 --> 03:47.560
Let's see if we have any.

03:47.590 --> 03:53.910
There are no darn campaigning, so no tools, ball and polls are correct, actually.

03:53.920 --> 03:58.570
Well, just for printing, I'm going to increase this delay a little bit because that's going to be

03:59.140 --> 04:02.300
a little bit too fast just for us to read the value.

04:02.710 --> 04:05.780
So a delay of 15 milliseconds will be good.

04:06.250 --> 04:08.230
I'm going to upload the code now.

04:10.570 --> 04:10.930
Loading.

04:11.080 --> 04:16.030
I'm going to say a monitor and you can see we go from zero.

04:16.540 --> 04:18.040
OK, it's increasing.

04:20.490 --> 04:29.170
A 150, 200 and then 200, you will see 255 and then we decrease the value.

04:29.710 --> 04:39.360
OK, so 100 year we go down and we are approaching zero and you will see here zero.

04:39.360 --> 04:41.820
And then we go up again.

04:42.880 --> 04:48.730
So now we are sure that the index here, the high value that we need for analysis, right.

04:48.920 --> 04:50.620
As the correct behavior.

04:50.830 --> 05:02.260
OK, so wait, we can do now is actually to set up the entity to define energy in 11 in the set of function,

05:02.260 --> 05:09.370
we are going to do in mode with energy in and output.

05:10.420 --> 05:17.680
And in the void now, instead of printing and so we can remove, that's actually going to come and it.

05:21.440 --> 05:26.510
Instead of printing, I we can directly do analog.

05:27.860 --> 05:37.610
Right, we've been and the venue, which we know is going from zero to fifty five here, is going to

05:37.610 --> 05:42.780
get back to Delate five milliseconds and then on the other phone.

05:43.910 --> 05:46.030
Analogue, right?

05:47.900 --> 05:48.090
The.

05:49.160 --> 05:56.030
Dean, I as well could use the same code, but he and I is going from two hundred fifty five to zero

05:56.450 --> 06:02.060
and also the delay pipe and let's run that code.

06:02.920 --> 06:06.770
So now we don't take the same way we directly the energy.

06:07.010 --> 06:14.230
And as you can see, the energy is fading and fading out just like we want it.

06:16.210 --> 06:23.470
So as you could see on this program, sometimes it's easier to break the program, break the project

06:23.680 --> 06:28.670
into different steps and try to validate each step one by one.

06:29.200 --> 06:34.740
Once you validate one step, like we hear with the index, we can go to the next step.

06:35.110 --> 06:40.560
And this way, creating product will be much easier for you and you will make much less errors.

06:41.110 --> 06:42.340
All right, congratulations.

06:42.340 --> 06:47.770
You have just finished this activity and now we are going to look at digital input.

06:47.770 --> 06:48.160
Beenz.
