Let's the balance the budget in the interim function here on the left, you have the code we have just
written with the intent and on the right I have but the code from the previous section when we bounced
the button in the loop.
So then you can have the reference and we can compare the two codes.
And if you correctly understood what we did in the balanced example, well, that will be quite easy
for you to understand how to do this with interest, because that's practically the same.
So first, we're going to need to create two vials and signed long last time, but then released.
So I'm naming it being released instead of but changed because we are only going to use it in the budget
released into it just to make more sense.
This and then unsigned long, we are going to add a delay of 50 milliseconds and that's OK.
This is the value I'm going to use.
You can try with a lower of value.
Depends on the results you get when you start the program.
So in the button released interregnum.
I have my two vials here and I said the flag, the button on its flag to true.
But actually before we do that, we are going to check the duration since the last time the button was
released and make sure this duration is greater than the Diebold's did.
The first we're going to need to use.
Means to get the time, no.
And then if time now minus last time, but released, I'm going to use this if the duration is greater
than the demands delay.
Then we can say that the last time the button was released is right now, OK, is equal to time now.
And in that case, I'm going to put this inside like this.
And that's pretty much it, though, as you can see, this is the exact same as what we did with the
debone example.
So if you don't fully understand, please go back to the DBMS explanation from the last section.
The difference here is that in the debates, we constantly also checked the state.
We don't really need because we know that when this Internet is triggered, we know that the button
has been running in the loop.
We needed it to check that we already know it.
And one thing is that we modified the last time button released in the interim.
So I'm going to put a volatile.
OK, in front of that veil for the demands daily, we use it, but we don't modify it.
So if you just read a viable, you don't need to put volatile.
However, if you modify it, you need volatile.
So we have volatile for last time, but generalized and for button release can add two variables that
we modify inside the Internet.
OK, and one quick note about Milice here is you should be really careful.
I'm going to talk about that in the next listen.
But you should be really careful about this.
Only use it at the beginning of the interrupt.
Wants to get the time now and know that after this it's not going to work.
OK, Milice only gives you the time, which is the time when to interrupt was triggered, but the time
functionality is kind of disabled inside.
Interrupt so don't do some actions here and then measure the time again with Moelis because that's not
going to work.
All right.
So now let's see if we can compile code.
OK, it's compiling and so now the functionality will be the exact same as you can see, we didn't change
anything in the set up in the loop function.
So whenever we Earley's the button, the entity will be toggled.
And just now we have the DBMS functionality added in the interrupt.
OK, but just one quick note I have to had.
OK, is that using the debone inside to interrupt is not the best solution actually here.
The problem comes from the hardware, from the budget.
So the best solution will be to use the hardware debone setup, which is outside of the scope of discourse.
But now, you know, you can do this.
So if you want to check on the Internet, you can search for the secret, OK, you will need a few different
components.
And this way you can ensure that the button doesn't bounce at all directly from the hardware.
The thing is that the button that I use and the push-Button that you certainly have with your kids is
quite a low quality push-button.
OK, so this is fine for any experimentation.
But now if you want to do other projects with pushbuttons, I encourage you to maybe to buy a better
quality one which already has a debone in it.
OK, so you don't even need to do the debone yourself with the hardware, all the software.
But if you just have this pushbutton, use the DBMS from the software and you should be fine.
But don't expect it to work 100 percent of the time.
And also, when you use the pushbutton, make sure it is correctly connected and not damaged, because
sometimes it's just about the connection and how you connect the button.
If one pin is not correctly connected, well, you may have some weird behavior.
OK, so that's not specific to the push-Button not to enter into work.
Well, and in the following of the course, we are going to use also interactive a different tools.
So it's different than a pushbutton and you will see that it would be actually quite convenient.