Let's start with violence, one of the most important concepts in programming, and before you learn
what is valuable, please let me explain to you quickly why you need them.
So here is the first program we have written to make an editor blink.
And as you can see, so we need first to initialize the entity by providing the PIN number.
And then when we want to use digital right.
We also need to provide the PIN number.
Look, in this program, whenever you want to change the data center, you use PIN number even when
you need to change these three times.
And this is maybe not the most convenient thing to do.
Also, this program is rather small, but now imagine that you have a program that is one hundred line
long and you need to change that seven times in the program.
Well, this is a quick way to make errors.
So here what we are going to do is we are going to use variables.
So I'm going to create just a viable and then explain what our variables, let's say, into the thing
is equal to 12.
So if I do this.
And I replaced where we've been.
All right, now, if I want to change the editing, I just need to change it once here.
OK?
And whenever I write any dippin the value here, so it will be replaced by 12.
OK, so no effect.
But even I have the same program.
But using the pin Edvin.
So what is a viable viable represents the stored value that you can reuse later in your program.
It's kind of a container and to make it easier to recognize it, you can give it to name.
So I'm going to create a new find.
And I'm going to create viable here to create a viable first, you need to give a type of data type.
So among the most common data type, you have it.
And you can see when I put it, you have the column.
So it means integer and it is a round number.
So, for example, zero one, two, three, but also in the negative like minus five, minus 10, etc..
So now you need to be the name.
Let's put a fono and a semicolon to declare the variable.
So there are actually two steps.
When you create a viable first, you need to declare eight and then you can initialize it so you can
give it a value.
So let's say but seven.
OK, and I don't forget the semicolon after initialized available here, I declare a viable.
There is no value in it.
And here I initialize the variable that was declared previously.
I can also initialize the variable in the setup and if I want, I can directly also initialize the variable
here.
So here I declare and I initialized available at the same time.
And what will happen here?
So first, the lines on the top of the program will be basically where you declare your valuables.
So this will be executed first.
And then, as you know, the void set up would be executed and then the loop would be executed forever.
So what will happen in this case is first we create a viable so we declare a and we initialize a two
five.
Not when we enter the setup.
We simply change the value inside.
A valuable is not a constant value unless you specify it.
It's a container where you can change the value at any moment.
Of course, you need to make sure this is the same data type.
So integer.
So let's for example, let's do that begin.
OK, with nine thousand six hundred, so print and then and yeah, before we have just printed some
text, but you can directly put the name of a valuable and this will print the name of the label.
So let's name this program violence.
OK, and make sure you already know is correctly connected, and now if I open the science monitor,
I will see the value seven, OK, because A was equal to five first and then I changed the value inside
A and I print an A whenever you use the name of available.
What we really happen in the program is that the name of the variable will be replaced what we call
evaluated to its value, which is said you can also use operators like plus minus etc. to put a value
inside of.
So not like this, we should see a equal to even.
OK, so now A is equal to error, and you can also use a viable to create another viable, let's say,
create another one.
So I could create that.
I'm going to create the I could create it here.
So declare it here, for example.
And then but B is equal to, let's say A plus or OK.
And let's print the.
So now A is equal to anyone at this line, and B will be equal to A plus false or B will be equal to
15.
So you can combine variables together and note that whenever you write a viable source, you write a
A will be evaluated to its last value.
So the value it has here and not the value here, OK.
The order of the instructions is very important.
Not if I do this, then you will see that B will not be equal to eight to 15.
Sorry, that will be equal to nine because it was five and five plus four equals nine and then eight
changes.
OK, so that basically is how you use violence.
And we are going to see more about that in the following of this course when we do many activities.
And I briefly talked about constant variables.
What are constant variables?
Well, as you can see, a variable is a continuum where you can change the value at any time.
But maybe you want to create some variables where the value can't be changed.
And why is that, for example?
Well, at the beginning of this lesson, I used available to store the PIN for analogy.
And the thing is that once you have put the pin for the eight, it's been twelve in your program.
You're not going to change it while you're on the program, OK?
When you run the program, the hardware set up doesn't change.
So in this case, you will use constants.
So there are different ways to create constants.
But here what I'm going to do is to use define so hashtag and define.
You can see here it should turn green.
OK, and then the convention to create variables which are constant is to use all the keys.
But it's been so all keys and separate the world with and underscore and then you put the value, you
don't put an equal sign.
OK, this is different.
So I shouldn't define the name of the variable in either case, the value of the value.
And now you can use that in your program.
And if you try to modify this, this simply won't work.
OK, so you have normal variables and variables that you don't want to change in your program.
So to quickly recap here, a valuable is a container you can use to store a value so that you can reduce
that value later in your program to create a viable without when you first need to declare it with a
name and a data type, then you can give it any value so you can initialize it here and give it any
value all along your program, just making sure that the value stays in the data that you have chosen
and you can create constant viable like this.