WEBVTT

00:00.480 --> 00:06.960
Let's the balance the budget in the interim function here on the left, you have the code we have just

00:06.960 --> 00:14.460
written with the intent and on the right I have but the code from the previous section when we bounced

00:14.460 --> 00:16.120
the button in the loop.

00:16.800 --> 00:20.430
So then you can have the reference and we can compare the two codes.

00:20.640 --> 00:27.030
And if you correctly understood what we did in the balanced example, well, that will be quite easy

00:27.030 --> 00:31.200
for you to understand how to do this with interest, because that's practically the same.

00:31.710 --> 00:41.370
So first, we're going to need to create two vials and signed long last time, but then released.

00:41.580 --> 00:48.240
So I'm naming it being released instead of but changed because we are only going to use it in the budget

00:48.240 --> 00:51.810
released into it just to make more sense.

00:52.850 --> 01:02.390
This and then unsigned long, we are going to add a delay of 50 milliseconds and that's OK.

01:02.440 --> 01:03.770
This is the value I'm going to use.

01:04.440 --> 01:07.530
You can try with a lower of value.

01:07.530 --> 01:10.740
Depends on the results you get when you start the program.

01:11.280 --> 01:13.620
So in the button released interregnum.

01:14.340 --> 01:19.410
I have my two vials here and I said the flag, the button on its flag to true.

01:20.100 --> 01:26.310
But actually before we do that, we are going to check the duration since the last time the button was

01:26.310 --> 01:30.140
released and make sure this duration is greater than the Diebold's did.

01:30.900 --> 01:32.730
The first we're going to need to use.

01:33.950 --> 01:36.140
Means to get the time, no.

01:38.680 --> 01:49.090
And then if time now minus last time, but released, I'm going to use this if the duration is greater

01:49.090 --> 01:50.350
than the demands delay.

01:53.540 --> 02:00.430
Then we can say that the last time the button was released is right now, OK, is equal to time now.

02:00.770 --> 02:05.330
And in that case, I'm going to put this inside like this.

02:06.970 --> 02:12.820
And that's pretty much it, though, as you can see, this is the exact same as what we did with the

02:12.820 --> 02:14.100
debone example.

02:14.110 --> 02:20.170
So if you don't fully understand, please go back to the DBMS explanation from the last section.

02:20.470 --> 02:26.910
The difference here is that in the debates, we constantly also checked the state.

02:27.580 --> 02:33.490
We don't really need because we know that when this Internet is triggered, we know that the button

02:33.490 --> 02:35.820
has been running in the loop.

02:35.830 --> 02:39.090
We needed it to check that we already know it.

02:39.460 --> 02:45.180
And one thing is that we modified the last time button released in the interim.

02:45.340 --> 02:47.140
So I'm going to put a volatile.

02:49.670 --> 02:55.860
OK, in front of that veil for the demands daily, we use it, but we don't modify it.

02:55.870 --> 02:59.520
So if you just read a viable, you don't need to put volatile.

03:00.020 --> 03:02.410
However, if you modify it, you need volatile.

03:02.490 --> 03:08.900
So we have volatile for last time, but generalized and for button release can add two variables that

03:08.900 --> 03:11.080
we modify inside the Internet.

03:11.470 --> 03:15.640
OK, and one quick note about Milice here is you should be really careful.

03:15.650 --> 03:17.900
I'm going to talk about that in the next listen.

03:17.900 --> 03:19.640
But you should be really careful about this.

03:20.010 --> 03:22.540
Only use it at the beginning of the interrupt.

03:22.580 --> 03:26.990
Wants to get the time now and know that after this it's not going to work.

03:27.050 --> 03:34.220
OK, Milice only gives you the time, which is the time when to interrupt was triggered, but the time

03:34.220 --> 03:37.010
functionality is kind of disabled inside.

03:37.070 --> 03:43.370
Interrupt so don't do some actions here and then measure the time again with Moelis because that's not

03:43.370 --> 03:43.970
going to work.

03:44.360 --> 03:44.720
All right.

03:44.720 --> 03:47.630
So now let's see if we can compile code.

03:49.070 --> 03:54.010
OK, it's compiling and so now the functionality will be the exact same as you can see, we didn't change

03:54.020 --> 03:56.410
anything in the set up in the loop function.

03:56.750 --> 04:00.700
So whenever we Earley's the button, the entity will be toggled.

04:01.160 --> 04:06.020
And just now we have the DBMS functionality added in the interrupt.

04:06.470 --> 04:09.160
OK, but just one quick note I have to had.

04:09.170 --> 04:15.910
OK, is that using the debone inside to interrupt is not the best solution actually here.

04:15.960 --> 04:18.540
The problem comes from the hardware, from the budget.

04:18.860 --> 04:24.670
So the best solution will be to use the hardware debone setup, which is outside of the scope of discourse.

04:24.680 --> 04:26.600
But now, you know, you can do this.

04:26.600 --> 04:32.390
So if you want to check on the Internet, you can search for the secret, OK, you will need a few different

04:32.390 --> 04:33.020
components.

04:33.260 --> 04:37.880
And this way you can ensure that the button doesn't bounce at all directly from the hardware.

04:38.450 --> 04:44.030
The thing is that the button that I use and the push-Button that you certainly have with your kids is

04:44.030 --> 04:46.040
quite a low quality push-button.

04:46.250 --> 04:49.670
OK, so this is fine for any experimentation.

04:49.940 --> 04:55.640
But now if you want to do other projects with pushbuttons, I encourage you to maybe to buy a better

04:55.640 --> 04:58.800
quality one which already has a debone in it.

04:58.870 --> 05:03.700
OK, so you don't even need to do the debone yourself with the hardware, all the software.

05:04.010 --> 05:10.240
But if you just have this pushbutton, use the DBMS from the software and you should be fine.

05:10.250 --> 05:13.010
But don't expect it to work 100 percent of the time.

05:13.460 --> 05:19.730
And also, when you use the pushbutton, make sure it is correctly connected and not damaged, because

05:19.730 --> 05:23.570
sometimes it's just about the connection and how you connect the button.

05:23.960 --> 05:28.240
If one pin is not correctly connected, well, you may have some weird behavior.

05:28.640 --> 05:33.410
OK, so that's not specific to the push-Button not to enter into work.

05:33.440 --> 05:39.520
Well, and in the following of the course, we are going to use also interactive a different tools.

05:39.800 --> 05:45.440
So it's different than a pushbutton and you will see that it would be actually quite convenient.
