Welcome back, guys.
So do you remember our circuit that we have designed in order to control this motor?
Well, how about we start sending statuses to our computer using this real monitor?
So assume that you have your Arduino set up and it's connected to the USB cable and you want to see
the status on your screen if you have it us to start or stop.
Well, remember, in order to do such messaging techniques, we can use our key protocol.
So how can we do that?
Well, simply in the set up, we're going to need to initialize you A.R.T. first to do this, we're
going to write the following function.
Cereal does not begin.
And we're going to set the transfer rate of the border eight to nine thousand six hundred.
OK, that's it.
By that, we are preparing the Turkey channel, which is usually connected through our USB cable to
our computer, and it is set to this nine thousand six hundred voudrais, and that is the transfer rate
we have learned about.
Remember, we need some fixed the transfer rate between our Adreno and the computer.
That is this Arduino is connected to.
Right.
So remember, this is a A.R.T. which is embedded inside this USB.
So next I'm going to go here and I'm going to write the following functions.
Now, remember, if we have an if statement and we have multiple conditions, we need to open a curly
bracket.
It's very important, so we open curly brackets and now we can put multiple instructions to be executed
if this condition is satisfied, if I remove these curly brackets and I write some function here.
It won't be part of my if statement at all, only this line, the one directly next to it, is going
to be affected by the statement and this will be a comment that will be executed every time in the loop.
This is not inside my if statement right now.
So to do this, we will add to curly brackets right here and then we write multiple instructions and
a whole block of code that will be executed only if the if statement is satisfied.
Well, what's next?
We're going to write serial, serial, dot print.
And I'm going to say here, motor has started.
The cynical.
So you say surreal print, you open a parenthesis and you write your message inside this double quotation,
right?
You you write a quotation, you write your message.
And whenever this condition is satisfied, you're going to see this message on the through your monitor,
which we will see in a minute.
Now, copy this exact line and just put it now in the OK.
Now, don't forget the curly brackets.
In order to execute a block of conditional statement.
That has put some spaces.
All right, so if if my stop button is pressed, I want to say his motor has stopped.
OK, so every time this line is executed, this will be printed every time this line is executed.
This will be printed.
So I can't keep track of what is.
Let's go to simulation.
And No.
I was up in my cereal monitor, this is the monitor.
Now, if I start.
As you can see, multiple Molterer has a story was printed and the motor is rotating, well, you might
ask well, I pressed it once, why the hell am I getting this?
Well, that is another issue and it is related to the bouncing, which we will talk about later, but
initially the message was printed.
Now, if I clear here, I cleared it.
And if I press this button again, multiple stock buttons are being printed as well.
Well, as I said, we will discuss this problem here, as we can see later, because it does not make
sense that I am going to print all of these statements with only one press.
OK, now how about we organize the seventh stop simulation?
As you can see, the lines are being printed all.
Head to tail, and that is a problem.
If I go and and replace the cereal print with cereal, print, l.n., same thing here.
This will give me a new line every time I tried to print something.
So it prints this and then it immediately tells the monitor to go to and your line.
So if I go to simulation again, I clear right here, if I start as you can see I have four or five
statements but they are line by line and that is easier visually if I stopped.
Again, multiple lines are being printed, so by that, we have learned a little bit about this moderate.
Now, in the upcoming lectures, we're going to learn about this phenomenon, which is called the Bouncing,
and we are going to learn how we can avoid these fluctuations in value.
But first, there is some Syntex techniques that I need to teach you.
I want to teach you as well about the bouncing in details.
Then at the end of this section, then after a couple of lectures, we're going to go back here and
I'm going to teach you how you can balance the value right to you and avoid all of these fluctuations.