WEBVTT

00:00.180 --> 00:08.070
This is the solution of the previous activity where you need to solve the problem back in the activity.

00:08.460 --> 00:15.750
So when we wanted to change the delay for the blink using the cellular communication, but what I'm

00:15.750 --> 00:19.290
going to do is I'm going to leave it like this.

00:19.300 --> 00:21.660
I'm going to create a new sketch.

00:21.660 --> 00:27.600
I'm going to copy the entire code here, this copy in that.

00:29.770 --> 00:36.330
New program and save it as we can just compile it and save it as activity.

00:41.210 --> 00:47.550
And no, let's fix that project, so I'm going to remove this first.

00:48.480 --> 00:57.120
And I'm going to go to the top and so we have the delay here and we just write the unsigned.

00:58.070 --> 01:10.730
Long previous time energy link initialised to minutes and then unsigned long time.

01:12.220 --> 01:18.490
Groveled So you can name it, actually, thank Devel all durational, actually, you can choose any

01:18.490 --> 01:19.220
name you want.

01:19.240 --> 01:23.610
Just make sure that it is meaningful and that you will understand it.

01:24.070 --> 01:28.660
And that if you look at the program in six months, you will still in the standard.

01:30.300 --> 01:31.870
And I think.

01:33.050 --> 01:40.670
And actually, here we have the blink delay, the blink delay is the same thing here as the time interval

01:40.670 --> 01:41.470
and blink.

01:41.870 --> 01:47.120
So when I have multiple choices here, I can just use blink delay like this, keep it like this, or

01:47.120 --> 01:49.160
I can just change the time interval.

01:49.530 --> 01:56.600
And if you blink and remove that, you what I'm going to do is simply instead of naming time into anything,

01:56.600 --> 01:58.170
I'm simply going to it.

01:58.490 --> 01:59.690
Blink delay.

02:00.330 --> 02:00.680
OK.

02:01.680 --> 02:08.610
And that will be basically the same thing, and I use also unsigned, long instead of ink, but here

02:08.610 --> 02:15.590
that will not make the difference because we know that the data is between one hundred and forty thousand.

02:15.600 --> 02:17.130
So both we want.

02:18.210 --> 02:19.620
Just going to remove that.

02:22.290 --> 02:23.940
We have the state.

02:25.290 --> 02:33.690
Great, and we already have the structure to toggle the ages to know what we need to add is the cost

02:33.720 --> 02:42.950
structure to replace the delay functionality and signed long time now is equal to miss.

02:43.560 --> 02:47.190
And then if time now minus.

02:48.280 --> 02:50.880
The previous time, he indeed.

02:52.210 --> 02:56.620
If this is greater than the blink delay.

02:57.770 --> 03:07.040
We can enter that if we can do the action, so I'm just going to let this control X control and fix

03:07.040 --> 03:08.100
the implementation.

03:09.300 --> 03:16.320
OK, if I click here, I see that this curly bracket goes with that one, but this is the code that

03:16.320 --> 03:18.900
should be indented, isolated and paystub.

03:20.060 --> 03:21.890
And then I do previews.

03:24.330 --> 03:30.400
Think link plus equal link Delate.

03:31.570 --> 03:34.990
And well, actually, that is pretty much it.

03:36.230 --> 03:42.860
Because here so we have structures, which means that this doesn't block the code for too long, just

03:42.860 --> 03:44.570
the time to execute the operations.

03:44.570 --> 03:44.870
Right.

03:45.410 --> 03:48.920
In the loop, we can go very fast by doing two actions.

03:49.280 --> 03:56.720
Check the cell communication if we have received some data and then make the lady blink if the timing

03:56.720 --> 03:57.440
is correct.

03:57.650 --> 04:04.580
So before what happens is that we enter the loop, we check this, we took the energy state and then

04:04.610 --> 04:05.390
we delay.

04:05.390 --> 04:12.680
We waited for quite a long time and then all over again, here we enter the loop, we check the same

04:12.680 --> 04:18.830
communication at the request, and then we check if we can make the link that the request and then we

04:18.830 --> 04:19.930
do it again back here.

04:20.390 --> 04:26.060
So the loop will be executed a much, much, much faster.

04:26.420 --> 04:33.350
And here maybe you would think that we need to use also the same structure to take if we can read from

04:33.350 --> 04:39.250
saying, OK, we the time, but actually we don't need to because this is really super fast.

04:40.010 --> 04:41.540
We are not blocking the code here.

04:41.550 --> 04:46.670
So no need to add a delay structure to the delay.

04:47.120 --> 04:52.940
We can just read from cellular communication at full speed every time we enter the loop.

04:52.940 --> 04:54.860
That will not slow down the program.

04:55.190 --> 04:55.520
All right.

04:55.520 --> 04:57.020
So now let's upload the code.

04:58.930 --> 05:04.780
But you can see the lady is blinking every five hundred milliseconds, I'm going to happen to say a

05:04.780 --> 05:13.750
monitor, let's I'm giving or thousands of maximum and now you will see immediately the aid starts to

05:13.750 --> 05:15.720
blink every four seconds.

05:15.770 --> 05:18.330
OK, I'm just going to give one hundred.

05:19.360 --> 05:22.290
I'm going to wait until now.

05:22.600 --> 05:26.890
And you can see directly the lady starts to blink at one hundred milliseconds.

05:27.220 --> 05:32.440
OK, we are not stuck for four seconds inside the by look.

05:33.880 --> 05:42.940
If I give three thousand and directly I give one hundred or just one hundred forty four, it starts

05:42.940 --> 05:48.560
to bring at four hundred forty four immediately, the delay changes immediately.

05:49.390 --> 05:49.840
All right.

05:49.850 --> 05:51.930
So that's the end of this activity.
