This is the solution of the previous activity where you need to complete this project to create a full
multitask project.
OK, by setting the analogy to write from the potential meter and by borrowing on the three when the
button is pressed.
OK, and what I'm going to do, because here it's activity nine.
So I'm not going to write code on this.
I'm going to write everything, copy everything, and then create a new project and then everything.
So we start on the new project that I am going to compile and save as activity in.
All right, so our first action, which is to change the delay for the blank, for any one, is already
done.
So not what we can do is to do this action, which is to set the energy brightness from the potential.
So the we need to hear the fine energy to in is Ongpin number 11 so we can use the PWI in functionality
on that.
People also here and I'm simply going to rename it as the one thing.
OK, I'm just going to add one little delay.
Let's see.
Anyone one, any one state.
Linda, that is one.
It just to make more sense.
Because we have multiple entities in here and it is one thing, and you are at any one state and one
state, you want also one here.
In and.
OK, let's just come by to see if I have any error, no.
OK, so if you just have one entity, then it's OK not to put a number on it, but here because we have
multiple ones, I just want to make sure that it will not be confusing later.
So we find Eddie to be 11.
This are having to initialize it here.
So queen mode up in output.
And then in the loop, we are going to sit brightness from the potential of this, so we need potentially
to define.
But extreme weather in which she's a tool, OK, we don't need to actually do spin mode because this
is an analog input being.
Right, and then in the loop, so what I'm going to do, I'm simply going to do the action here, OK,
so we have action one.
According to.
And then action three, action three is simply to get the put on shareholder value put on Shimura.
Value is equal to analog radio.
OK, with the lunchmeat a cleaner.
All right, now we can do.
In intensity.
Which will be put on Sumate.
Value divided by four.
OK, if you remember, the value we get from an is between zero and one thousand twenty three and the
value we can give with the analog right function is between zero and two hundred fifty five.
So we need to divide the value by four.
So, Andrew, great to write on PIN number 11 with the W.M. function.
And to deal with intensity.
And that is the action three and here, this will not pose any problem because this is quite fast,
OK, we use an override function, so this will not block the code for too long.
Then we just do an operation and we are going to go, right, OK.
We don't use any delay, though, because we don't use the delay.
We don't need to use that structure.
It does structure is only when you use delay and basically only when you want to wait a certain time
before you do a different action.
So here, if we wanted, for example, to update the energy intensity, but not every time we enter
the loop, but instead, for example, every three hundred milliseconds, what we could do is use this
structure.
But because we want to do it as fast as possible.
Well, that's not a problem.
And now the action for.
Which is simply too poor on the third when we raise the budget, so we need to find a way in which it's
been a 10, I'm going to initialize it here.
Mode.
A.
Three in.
And we also need.
Who define.
Button.
In which he has been number two, the digital pin number two, and also teen mode button pin.
In what?
We have initially been not in the loop, we can do the action, so now what we can do is check if.
Digital read Butterbean.
Is equal to I wish to equal saying.
Then we enter this book of code and we put on so digital.
Right.
Ali.
Three senior.
We've high we report on the 83 and of course, don't forget the elsea.
If the button is not pressed, we need to pull off digital, right, and the thing we need to pull it
off.
All right.
And that's it.
So as you can see, this also doesn't need a delay, OK, because we want to update this as fast as
possible, as fast as we did the data, just as we did here.
So if you wanted to update only every one hundred milliseconds and you would have used a structure like
this.
OK, but we disagree with you.
What I want to show you is that create a multitask program.
You simply need to do all the operations, OK, all the actions you want to function one by one.
Just make sure that no action is blocking the execution.
OK, because here we have four different actions no one is blocking will delay, which means that they
are going to be executed very, very fast.
So because they are executing very, very fast, then it's almost like they are executed at the same
time.
And this is where you have the multitask program.
All right, and now let's applaud that programme to our Adreno.
All right.
And you can see here, so we have our first energy, which blinks every five hundred milliseconds,
let's say, on monitor.
And I can just change it.
Let's say 200.
It blinks much faster.
Let's say three dozen.
It blinks every three seconds.
OK, and we have our second lady here, you can see is already power on it, but because this is from
the bottom shmita, I can increase and decrease the value, as you can see from the bottom me, that
this is happening at the same time as the first lady blink.
And what I can do is from the bottom, I can also power on the third and this and I can do everything
at the same thing.
OK, yeah.
And moving the production meter, I put on the push button, I press the button at the same time you
can see the first lady is still blinking.
So everything is happening at the same time.
All right, so that's the end of this activity.
Now, you should have a better understanding on how to use the time functionalities so you can avoid
using delay in the volume function and you can create as many actions as you want.
OK, you just need to put all the actions in the order you want and then they are going to be executed
so fast, which means that you have created a multitask program.
Congratulations.
That's the great progress you have just made.