WEBVTT

00:00.270 --> 00:07.050
In this activity, we are actually going to start from the code, from the previous activity, so I

00:07.050 --> 00:14.250
have here created a new file and I just took the entire code from the previous HDD, which already works.

00:14.460 --> 00:20.010
And the goal of this activity is to practice with functions, arrays and folders.

00:20.520 --> 00:23.230
So we are going to improve that program.

00:23.380 --> 00:28.550
OK, we're going to keep the exact same functionality, but improve that program.

00:29.160 --> 00:31.770
So what are you going to do here?

00:32.040 --> 00:39.500
Well, first, you can see we have three entities and we handle you can see here we do promote multimode

00:39.750 --> 00:40.130
digital.

00:40.140 --> 00:41.160
Right, right.

00:41.490 --> 00:41.910
Right.

00:42.450 --> 00:45.630
So this is quite a lot of repetition in the code.

00:46.050 --> 00:53.850
So what you do is you will create an array to contain the things for the entities.

00:54.180 --> 01:01.800
And then let's say here for all the modes you are going to instead of writing code three times, you

01:01.800 --> 01:07.760
are going to create a follow up, go through all the pins and set all the pins to.

01:09.090 --> 01:16.580
The same goes for the initialization return of all it is you are going to create here a or.

01:17.870 --> 01:25.340
And then as a second step, what you are going to do is put this into a function, so to set the mood

01:25.340 --> 01:34.940
for the things and then this into another function, to turn off all the attendees and then this cue

01:35.060 --> 01:37.250
this block of code.

01:39.120 --> 01:46.680
Where you toggle the state, you are also going to put it inside a function that DNA will have one,

01:47.130 --> 01:54.490
two and three functions, so the void setup and the void loop functions will be much more later.

01:55.290 --> 01:58.680
And just going to give you a few tips to get started.

01:59.130 --> 02:00.890
So let's actually create the array.

02:00.900 --> 02:03.870
So just continue here in the global scope.

02:04.320 --> 02:06.020
The first you need to give a type.

02:06.360 --> 02:08.910
And what is the type of this?

02:08.910 --> 02:16.990
Well, the type of this, the type of the pins here is actually not exactly inert, but instead bite.

02:17.550 --> 02:18.480
OK, what is Bayt?

02:18.870 --> 02:20.520
Is it the first time we use bite?

02:20.880 --> 02:27.990
You have heard previously that, for example, I said integer is stored on two bytes and along is stored

02:27.990 --> 02:37.140
on four bytes case or that is simply that I type which contains wrong numbers from zero to two hundred

02:37.380 --> 02:38.420
and fifty five.

02:39.030 --> 02:42.330
If you remember from what we did with the analog right.

02:42.330 --> 02:43.980
Function with repeatably when.

02:43.980 --> 02:48.000
Well that's exactly disarranged a bit a brain function.

02:48.000 --> 02:54.840
Actually the parameter that you sent to it in the right was about nothing really complicated about is

02:54.850 --> 02:59.130
simply an integer but smaller just on one byte.

02:59.140 --> 03:01.060
So zero to two hundred fifty five.

03:01.590 --> 03:07.890
So the name for the array will be in the right it.

03:08.040 --> 03:10.830
So you can choose this name and then you need to give.

03:12.010 --> 03:18.910
The site is the site would be three, but actually instead of help getting the site, we can maybe create.

03:20.350 --> 03:25.990
Another defining entity in the right.

03:27.250 --> 03:28.050
It's a.

03:29.450 --> 03:30.740
This is quite explicit.

03:32.990 --> 03:35.000
It's been a recital three.

03:35.020 --> 03:37.090
And then we simply do this.

03:39.000 --> 03:39.840
Right here.

03:41.130 --> 03:46.740
All right, so this is better because if we want, for example, to add a new entity, we simply add

03:46.740 --> 03:53.640
a new entity, we simply increase by one year and let's initialize the area that we are simply going

03:53.880 --> 03:55.950
to give into the three brackets.

03:57.070 --> 03:58.270
And the one being.

03:59.280 --> 04:01.020
And then energy to pin.

04:02.070 --> 04:04.880
And then at three know.

04:07.750 --> 04:18.070
And use a semicolon and as you can see here, we have a quite long line, OK, and it's quite recommended

04:18.070 --> 04:21.050
when you program to keep lines quite short.

04:21.230 --> 04:27.970
OK, so here in my program, I have found 18 and to make it more readable, what I can do is simply

04:27.970 --> 04:35.530
after the equals sign here, I'm going to press enter and this price tag puts a few times doesn't really

04:35.530 --> 04:35.970
matter.

04:36.310 --> 04:43.820
And just put this on a new line if you have this, but equal sign and then something on the new line.

04:43.840 --> 04:45.990
Well, this is the following of the statements.

04:45.990 --> 04:49.660
So is just like it was one line, but it's much more reliable.

04:49.680 --> 04:53.840
OK, have the time, array the size and then you see the values here.

04:54.460 --> 04:54.810
All right.

04:54.820 --> 05:02.260
So you have the array and then you can use this right to actually that's the pin mode that the digital

05:02.260 --> 05:05.920
right initialize the any and the function.

05:05.960 --> 05:09.850
So here just going to give you the name of the function.

05:09.880 --> 05:15.430
So this would be a void function mode and you can name it, for example, said LTT.

05:16.610 --> 05:17.720
Incommode.

05:19.560 --> 05:22.070
And here you can, for example, it.

05:23.450 --> 05:26.480
Then of all these.

05:29.090 --> 05:35.180
OK, so you trade to function here on the top of the program after the initialization of the valuables

05:35.180 --> 05:41.420
and constant and insider function, use a follow up to go through all of the ends of the.

05:43.200 --> 05:49.410
And then for this, but you can use a function, let's say.

05:51.210 --> 05:54.780
Which name is Pogo, and it is.

05:57.150 --> 06:02.490
All right, so now you have enough information to work on and I will see you in the next listen for

06:02.490 --> 06:03.120
the solution.
