This is the solution of the previous activity where you need to solve the problem back in the activity.
So when we wanted to change the delay for the blink using the cellular communication, but what I'm
going to do is I'm going to leave it like this.
I'm going to create a new sketch.
I'm going to copy the entire code here, this copy in that.
New program and save it as we can just compile it and save it as activity.
And no, let's fix that project, so I'm going to remove this first.
And I'm going to go to the top and so we have the delay here and we just write the unsigned.
Long previous time energy link initialised to minutes and then unsigned long time.
Groveled So you can name it, actually, thank Devel all durational, actually, you can choose any
name you want.
Just make sure that it is meaningful and that you will understand it.
And that if you look at the program in six months, you will still in the standard.
And I think.
And actually, here we have the blink delay, the blink delay is the same thing here as the time interval
and blink.
So when I have multiple choices here, I can just use blink delay like this, keep it like this, or
I can just change the time interval.
And if you blink and remove that, you what I'm going to do is simply instead of naming time into anything,
I'm simply going to it.
Blink delay.
OK.
And that will be basically the same thing, and I use also unsigned, long instead of ink, but here
that will not make the difference because we know that the data is between one hundred and forty thousand.
So both we want.
Just going to remove that.
We have the state.
Great, and we already have the structure to toggle the ages to know what we need to add is the cost
structure to replace the delay functionality and signed long time now is equal to miss.
And then if time now minus.
The previous time, he indeed.
If this is greater than the blink delay.
We can enter that if we can do the action, so I'm just going to let this control X control and fix
the implementation.
OK, if I click here, I see that this curly bracket goes with that one, but this is the code that
should be indented, isolated and paystub.
And then I do previews.
Think link plus equal link Delate.
And well, actually, that is pretty much it.
Because here so we have structures, which means that this doesn't block the code for too long, just
the time to execute the operations.
Right.
In the loop, we can go very fast by doing two actions.
Check the cell communication if we have received some data and then make the lady blink if the timing
is correct.
So before what happens is that we enter the loop, we check this, we took the energy state and then
we delay.
We waited for quite a long time and then all over again, here we enter the loop, we check the same
communication at the request, and then we check if we can make the link that the request and then we
do it again back here.
So the loop will be executed a much, much, much faster.
And here maybe you would think that we need to use also the same structure to take if we can read from
saying, OK, we the time, but actually we don't need to because this is really super fast.
We are not blocking the code here.
So no need to add a delay structure to the delay.
We can just read from cellular communication at full speed every time we enter the loop.
That will not slow down the program.
All right.
So now let's upload the code.
But you can see the lady is blinking every five hundred milliseconds, I'm going to happen to say a
monitor, let's I'm giving or thousands of maximum and now you will see immediately the aid starts to
blink every four seconds.
OK, I'm just going to give one hundred.
I'm going to wait until now.
And you can see directly the lady starts to blink at one hundred milliseconds.
OK, we are not stuck for four seconds inside the by look.
If I give three thousand and directly I give one hundred or just one hundred forty four, it starts
to bring at four hundred forty four immediately, the delay changes immediately.
All right.
So that's the end of this activity.