Let's create your first real original program.
I'm going to do this with the original idea and real alienable.
If you just want to use the simulation, please make sure that you watch this list first.
And I'm going to do a simulation and take a look at it in a few lessons directly on this section.
And also, if you don't understand some parts of the code here, all the different instructions we are
going to you don't worry too much.
We will cover everything in the following of discourse.
For now, the most important thing you can do is to get a program running to actually get fitting out
how it works.
So what are we going to do in this first program?
Well, there is an already existing directly integrated on the added world, so we don't need to add
any external hardware.
We can just try to make this blink that depending on your innovation, the energy may be located in
a different place, but it will not be very hard to find.
So back to our program here.
You have four setup and void loops.
Now, you know, that void setup is the function that would be called first and would be called only
once, and then Void Loop will be called after setup and would be called an infinite amount of time
until you simply restart our power of your autonomy.
So because we are using an energy, we need to set it up on the void, set the function OK, and the
LDA is actually connected to a digital piñon.
Alino.
Also, we are going to see what our digital means a little bit later on this discourse.
And the first thing we need to do when we use a digital pen is actually to set it up with the pin mode
function.
So lowercase and then m uppercase mode.
And you can see it should turn orange or at least a different color.
OK, if you have this, it's good means that the function has been recognized as an additive function.
So the number of the thing here is 13.
This is simply the pin where the entity, the integrated ality is connected to and then we can put a
comma.
So we open the door onto this thing, can put a comma and then all uppercase outputs and this should
blue here.
We close the power outages and we add a semicolon.
Semicolon is very important.
It means that this is the end of one instruction.
So basically you are going to write the code.
So one instruction per line.
But this is not what defines the limits between instruction.
The limit between instructions is this semicolon.
Do you forget a semicolon?
You will probably get an error here when you try to compile a code.
So make sure you don't forget that.
All right.
And you can see here we have a command.
Maybe we can remove that command, but your set of code here to run one.
So we already know that.
And maybe we can just add a new command here, let's say set.
Ever been to Output's, so this is just a come on, so this line will not be executed, but you can
see your comment is very useful to say what we are going to do or to explain the next line.
So this line is pretty obvious, but you can get a feeling of how to use commands.
Great.
So now the vote setup will be executed once the mode will be set to output.
OK, we have input and output.
We select output because this is an energy.
We want to control the energy.
So output and then in the loop, something to remove also that command that we don't need.
So in the loop we are going to make the blink.
So the first thing we can do is to call the function the detail.
Right.
So again, you should see it turning orange digital and then right with the case, we open the term
to this and now we need to give also the name of the pin.
So the number of the beam 13 like we here and here, we need to simply put high or low.
So I'm going to but I always advocate here, OK, we should turn blue, I close the parentheses and
I don't forget the semicolon.
So this is basically will tell the pin number 13 to hide two state high.
And what this means with the entity is that the LDA will be powered on.
Also, one little note here.
You can see we have an indentation of two spaces here.
So in addition, is actually not required for the prompt to work.
This is just for readability.
OK, so whenever enter a new block of code like this, we've got brackets.
I'm going to use two new spaces for indentation.
And after we have poured on the new ones, we want to do if we want to make blank is of course we need
to pull it off.
So digital, right?
We've been 13 the same and then Lo and O.W. we close the boundaries and the semicolon.
All right.
Now, the thing is, if we just start the program like this, what will happen is you will see the LDA
always higher, are always Powelton.
And this is because, well, the code inside the void loop will be run at full speed and full speed
for Arduino is a few hundred megahertz.
So when you compare that to what we as humans are able to see, well, this is way too fast for us to
see the energy blink.
So what do we need to do is to add a small delay?
OK, we need to make a prime stop between those two instructions, OK?
And what we are going to do is to use the function delay.
OK, so delay like this with parentheses and let's put one thousand were closed apprentice's and semicon.
So delay we simply stop here for the amount of millisecond that you provide here.
This is that signal.
This is merely Segan.
The one thousand milliseconds means one thing.
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,
we wait for once again, then we pull off the energy.
And then what will happen here is that we directly come back to the beginning of the voice function.
So just after we pull it off and we are going to put on the energy.
So we do also add a delay here.
OK, because otherwise we will not be able to see the world of but it will directly be pulled on just
after that.
All right.
I know the program is complete.
So if you want, you could add also different comments here to describe what you are doing and to make
sure you understand how the loop works.
Well, basically, I could just copy and paste that code an infinite number of times, OK?
And this is how the code would be executed.
Instead, I just need to provide the code once.
And I know that after line 10, so we close the loop function, the loop function would be called again
and we go back to line seven.
All right.
It looks good.
So now we can upload this program to our alienable.
The first thing I'm going to do is I'm going to compile what it is but verify.
But then I'm going to compile the code and it will ask you to save the sketch.
So we already know a program is called a sketch.
OK, so it will ask you to say Skagen, you what you can do is simply give a name that's say first program.
Say, OK, it will combine.
And let's see if we have any hero.
OK, you can see here, Don, compiling, so if you have this, it means it was successful and you have
some information about space use age and stuff like this.
Now, let's say that I forgot the semicolon here and I verify it again.
So when I verify it will see the final result.
And you can see here we have an error.
So I have quite a bit of text and then you can see expected semicolon before delay.
So if you make some error, you will get an explanation here.
So the explanation may be clear or not so clear.
Depends what kind of error you make, but it's quite clear.
OK, before the delay, we do not have any semicolon.
I'm going to add it here and now it works.
OK, so plug your alienable to your computer and then with tools bold and make sure that the correct
word is seated.
So for me, it is arduino you and make sure that you have the correct.
But now I can upload the code.
You can see Don applauding and we can see here that the entity on the alino is linking every one Segan.