WEBVTT

00:00.330 --> 00:03.540
Let's create your first real original program.

00:04.080 --> 00:08.850
I'm going to do this with the original idea and real alienable.

00:09.210 --> 00:14.690
If you just want to use the simulation, please make sure that you watch this list first.

00:14.730 --> 00:20.940
And I'm going to do a simulation and take a look at it in a few lessons directly on this section.

00:21.240 --> 00:26.940
And also, if you don't understand some parts of the code here, all the different instructions we are

00:26.940 --> 00:29.230
going to you don't worry too much.

00:29.490 --> 00:32.520
We will cover everything in the following of discourse.

00:32.760 --> 00:40.400
For now, the most important thing you can do is to get a program running to actually get fitting out

00:40.560 --> 00:42.000
how it works.

00:42.270 --> 00:45.510
So what are we going to do in this first program?

00:45.540 --> 00:53.520
Well, there is an already existing directly integrated on the added world, so we don't need to add

00:53.520 --> 00:55.700
any external hardware.

00:55.890 --> 01:03.990
We can just try to make this blink that depending on your innovation, the energy may be located in

01:03.990 --> 01:08.010
a different place, but it will not be very hard to find.

01:08.550 --> 01:10.410
So back to our program here.

01:10.530 --> 01:13.140
You have four setup and void loops.

01:13.230 --> 01:19.590
Now, you know, that void setup is the function that would be called first and would be called only

01:19.740 --> 01:26.760
once, and then Void Loop will be called after setup and would be called an infinite amount of time

01:27.480 --> 01:31.680
until you simply restart our power of your autonomy.

01:32.070 --> 01:41.580
So because we are using an energy, we need to set it up on the void, set the function OK, and the

01:41.580 --> 01:45.260
LDA is actually connected to a digital piñon.

01:45.350 --> 01:45.720
Alino.

01:45.720 --> 01:49.620
Also, we are going to see what our digital means a little bit later on this discourse.

01:49.950 --> 01:56.580
And the first thing we need to do when we use a digital pen is actually to set it up with the pin mode

01:56.580 --> 01:57.230
function.

01:57.630 --> 02:02.310
So lowercase and then m uppercase mode.

02:02.310 --> 02:06.300
And you can see it should turn orange or at least a different color.

02:06.350 --> 02:13.130
OK, if you have this, it's good means that the function has been recognized as an additive function.

02:13.290 --> 02:16.130
So the number of the thing here is 13.

02:16.680 --> 02:25.500
This is simply the pin where the entity, the integrated ality is connected to and then we can put a

02:25.500 --> 02:26.080
comma.

02:26.610 --> 02:34.360
So we open the door onto this thing, can put a comma and then all uppercase outputs and this should

02:34.800 --> 02:35.720
blue here.

02:36.750 --> 02:40.320
We close the power outages and we add a semicolon.

02:40.650 --> 02:42.890
Semicolon is very important.

02:43.320 --> 02:47.230
It means that this is the end of one instruction.

02:47.700 --> 02:49.800
So basically you are going to write the code.

02:50.210 --> 02:52.050
So one instruction per line.

02:52.380 --> 02:56.310
But this is not what defines the limits between instruction.

02:56.370 --> 02:59.250
The limit between instructions is this semicolon.

02:59.550 --> 03:01.080
Do you forget a semicolon?

03:01.180 --> 03:05.570
You will probably get an error here when you try to compile a code.

03:05.760 --> 03:07.010
So make sure you don't forget that.

03:07.340 --> 03:07.710
All right.

03:07.720 --> 03:09.840
And you can see here we have a command.

03:09.850 --> 03:14.130
Maybe we can remove that command, but your set of code here to run one.

03:14.130 --> 03:15.600
So we already know that.

03:16.230 --> 03:21.480
And maybe we can just add a new command here, let's say set.

03:22.920 --> 03:33.150
Ever been to Output's, so this is just a come on, so this line will not be executed, but you can

03:33.150 --> 03:38.900
see your comment is very useful to say what we are going to do or to explain the next line.

03:39.180 --> 03:44.340
So this line is pretty obvious, but you can get a feeling of how to use commands.

03:44.650 --> 03:44.910
Great.

03:44.920 --> 03:51.290
So now the vote setup will be executed once the mode will be set to output.

03:51.330 --> 03:53.850
OK, we have input and output.

03:54.240 --> 03:56.460
We select output because this is an energy.

03:56.460 --> 03:58.200
We want to control the energy.

03:58.200 --> 04:03.700
So output and then in the loop, something to remove also that command that we don't need.

04:04.590 --> 04:07.940
So in the loop we are going to make the blink.

04:08.820 --> 04:13.330
So the first thing we can do is to call the function the detail.

04:13.890 --> 04:14.430
Right.

04:14.460 --> 04:23.850
So again, you should see it turning orange digital and then right with the case, we open the term

04:23.850 --> 04:26.850
to this and now we need to give also the name of the pin.

04:26.850 --> 04:34.080
So the number of the beam 13 like we here and here, we need to simply put high or low.

04:34.230 --> 04:41.280
So I'm going to but I always advocate here, OK, we should turn blue, I close the parentheses and

04:41.280 --> 04:43.510
I don't forget the semicolon.

04:43.980 --> 04:51.030
So this is basically will tell the pin number 13 to hide two state high.

04:51.390 --> 04:56.540
And what this means with the entity is that the LDA will be powered on.

04:56.910 --> 04:58.860
Also, one little note here.

04:58.860 --> 05:02.940
You can see we have an indentation of two spaces here.

05:03.180 --> 05:07.470
So in addition, is actually not required for the prompt to work.

05:07.740 --> 05:09.550
This is just for readability.

05:09.580 --> 05:14.250
OK, so whenever enter a new block of code like this, we've got brackets.

05:14.460 --> 05:19.080
I'm going to use two new spaces for indentation.

05:19.440 --> 05:25.530
And after we have poured on the new ones, we want to do if we want to make blank is of course we need

05:25.530 --> 05:27.380
to pull it off.

05:27.540 --> 05:30.270
So digital, right?

05:30.690 --> 05:39.960
We've been 13 the same and then Lo and O.W. we close the boundaries and the semicolon.

05:40.590 --> 05:41.070
All right.

05:41.550 --> 05:48.240
Now, the thing is, if we just start the program like this, what will happen is you will see the LDA

05:48.330 --> 05:50.660
always higher, are always Powelton.

05:50.880 --> 05:58.290
And this is because, well, the code inside the void loop will be run at full speed and full speed

05:58.290 --> 06:01.230
for Arduino is a few hundred megahertz.

06:01.960 --> 06:09.690
So when you compare that to what we as humans are able to see, well, this is way too fast for us to

06:09.690 --> 06:10.980
see the energy blink.

06:11.250 --> 06:14.920
So what do we need to do is to add a small delay?

06:14.970 --> 06:19.970
OK, we need to make a prime stop between those two instructions, OK?

06:20.220 --> 06:23.250
And what we are going to do is to use the function delay.

06:23.440 --> 06:33.990
OK, so delay like this with parentheses and let's put one thousand were closed apprentice's and semicon.

06:34.410 --> 06:41.420
So delay we simply stop here for the amount of millisecond that you provide here.

06:41.850 --> 06:42.820
This is that signal.

06:42.840 --> 06:44.220
This is merely Segan.

06:44.610 --> 06:47.950
The one thousand milliseconds means one thing.

06:48.180 --> 06:57.480
OK, so if we look at how the program will be run so far the setup and then the loop we put on the LDA,

06:57.900 --> 07:01.590
we wait for once again, then we pull off the energy.

07:02.130 --> 07:07.240
And then what will happen here is that we directly come back to the beginning of the voice function.

07:07.620 --> 07:12.780
So just after we pull it off and we are going to put on the energy.

07:12.780 --> 07:14.910
So we do also add a delay here.

07:18.150 --> 07:27.590
OK, because otherwise we will not be able to see the world of but it will directly be pulled on just

07:27.590 --> 07:28.090
after that.

07:28.460 --> 07:28.850
All right.

07:28.850 --> 07:30.100
I know the program is complete.

07:30.110 --> 07:36.650
So if you want, you could add also different comments here to describe what you are doing and to make

07:36.650 --> 07:38.320
sure you understand how the loop works.

07:38.330 --> 07:46.060
Well, basically, I could just copy and paste that code an infinite number of times, OK?

07:46.070 --> 07:48.500
And this is how the code would be executed.

07:48.710 --> 07:52.040
Instead, I just need to provide the code once.

07:52.280 --> 07:59.360
And I know that after line 10, so we close the loop function, the loop function would be called again

07:59.750 --> 08:01.190
and we go back to line seven.

08:01.550 --> 08:02.080
All right.

08:02.090 --> 08:02.660
It looks good.

08:02.660 --> 08:05.910
So now we can upload this program to our alienable.

08:06.590 --> 08:10.720
The first thing I'm going to do is I'm going to compile what it is but verify.

08:10.760 --> 08:16.480
But then I'm going to compile the code and it will ask you to save the sketch.

08:16.490 --> 08:20.090
So we already know a program is called a sketch.

08:20.190 --> 08:28.450
OK, so it will ask you to say Skagen, you what you can do is simply give a name that's say first program.

08:29.620 --> 08:32.200
Say, OK, it will combine.

08:33.870 --> 08:36.510
And let's see if we have any hero.

08:39.070 --> 08:45.520
OK, you can see here, Don, compiling, so if you have this, it means it was successful and you have

08:45.520 --> 08:49.420
some information about space use age and stuff like this.

08:49.690 --> 08:55.300
Now, let's say that I forgot the semicolon here and I verify it again.

08:55.300 --> 08:57.600
So when I verify it will see the final result.

08:58.150 --> 09:00.870
And you can see here we have an error.

09:00.910 --> 09:08.350
So I have quite a bit of text and then you can see expected semicolon before delay.

09:08.710 --> 09:11.750
So if you make some error, you will get an explanation here.

09:11.780 --> 09:14.960
So the explanation may be clear or not so clear.

09:15.360 --> 09:18.420
Depends what kind of error you make, but it's quite clear.

09:18.730 --> 09:22.500
OK, before the delay, we do not have any semicolon.

09:22.600 --> 09:25.700
I'm going to add it here and now it works.

09:26.560 --> 09:35.890
OK, so plug your alienable to your computer and then with tools bold and make sure that the correct

09:35.890 --> 09:36.770
word is seated.

09:36.790 --> 09:41.170
So for me, it is arduino you and make sure that you have the correct.

09:41.170 --> 09:44.740
But now I can upload the code.

09:47.410 --> 09:55.630
You can see Don applauding and we can see here that the entity on the alino is linking every one Segan.
