WEBVTT

00:00.180 --> 00:07.320
And this is the solution to a previous activity where you need to set the brightness of the energy directly

00:07.320 --> 00:08.570
from the potential emitter.

00:09.090 --> 00:18.630
So let's begin by the beginning and let's first create a defined for the energy bill and for the potential.

00:19.440 --> 00:25.010
So everything is still being driven and then define what an shmita.

00:28.470 --> 00:34.110
Which is number eight to all right in the center.

00:34.170 --> 00:35.920
So what do we need to set up?

00:36.530 --> 00:41.350
We need to set up the area for sure demoed because this is a digital thing.

00:42.140 --> 00:46.470
So and we need to set it as an output.

00:47.730 --> 00:53.940
OK, so that wait, no, know, not the potential amount of pain is an analog input means that we don't

00:53.940 --> 00:55.160
need to use B mode.

00:55.170 --> 00:57.570
It's already input B also.

00:57.570 --> 00:59.030
We don't need to yell here.

00:59.070 --> 01:03.030
So we are not going to and should I say also that's it for a setup function.

01:03.840 --> 01:05.190
We have our Thain's.

01:06.110 --> 01:12.050
Everything is set up now in the loop, we can start the main program, so what we are going to do,

01:12.320 --> 01:19.250
we are going to read the value from the pot on Shimano and provide this value to the entity that with

01:19.550 --> 01:24.980
this modification here where we need to scale down the value from the analog rate.

01:25.430 --> 01:29.360
So what I'm going to do first is to create a viable integer viable.

01:29.680 --> 01:31.040
OK, but on Schmitter.

01:33.370 --> 01:42.960
Value, which will store the value from the analog read function, so analog read and we provide the

01:42.960 --> 01:44.180
production with a peno.

01:45.590 --> 01:50.420
All right, so when we do that, this will return a value between zero and one thousand twenty three,

01:50.990 --> 01:53.510
which we store into that value.

01:54.640 --> 02:00.220
And I'm going to create that's another variable which will be added brightness.

02:01.470 --> 02:04.170
And this will be what I'm Schmitter.

02:05.550 --> 02:10.980
Value divided by four, I compute this.

02:11.000 --> 02:17.410
OK, so this will basically scale this down to zero and 255 to approximately.

02:17.510 --> 02:22.500
OK, we don't need to be super precise here that we divide the value by four.

02:22.530 --> 02:24.720
And then what we do is analog.

02:26.470 --> 02:30.530
Right before, right, we need to provide two parameters.

02:30.550 --> 02:32.380
First is the bin.

02:33.840 --> 02:35.130
And then the value.

02:35.160 --> 02:37.350
So the value is any brightness.

02:43.290 --> 02:48.450
And said, well, we don't really need to delay, we can just do that at full speed.

02:48.480 --> 02:49.860
OK, that's not really a problem.

02:50.400 --> 02:54.450
So to recap, first we define the beans as always.

02:54.450 --> 02:58.060
We set up the mode for the LDP as an output pin.

02:58.120 --> 03:01.230
OK, we read the value from the pot on Schmitter.

03:01.240 --> 03:06.570
We cannot agree to function these returns a value between zero and one thousand twenty three.

03:06.990 --> 03:14.260
We still add value and then we create another valuable to store the new value for the which is the punishment

03:14.280 --> 03:16.320
of a divided by four.

03:16.610 --> 03:20.580
So we take down the value and then we analog write.

03:20.580 --> 03:28.790
We can write on the digital bin for the entity and provide a policy in and duty cycle of the period.

03:28.870 --> 03:33.050
Um, is the any brightness between zero and two hundred twenty five.

03:33.720 --> 03:39.510
So again, make sure I agreed to read an analog input being an analog.

03:39.520 --> 03:39.960
Right.

03:39.990 --> 03:44.930
This is to write on a digital bin with the living functionality of it.

03:44.940 --> 03:46.950
Don't make the confusion between them.

03:47.760 --> 03:53.510
All right, so let's just compile a code to see if it's just working activity.

03:57.830 --> 04:03.380
It's done complaining, so we don't have any error, if you have an error here, then you fix the problem

04:03.380 --> 04:04.970
and you try to combine again.

04:05.270 --> 04:08.050
And no, that's the code.

04:09.800 --> 04:17.090
Right, the court is applauded and as you can see, so the energy is boiled on here because simply the

04:17.090 --> 04:21.820
put on trimethyl is at some point between the minimum and maximum and the minimum.

04:22.220 --> 04:25.340
So we have this energy here with this brightness.

04:25.340 --> 04:32.660
And no, I'm going to move the matter here back to the minimum and you can see the energy just fade

04:32.660 --> 04:33.020
out.

04:34.160 --> 04:35.150
I'm going to turn.

04:36.390 --> 04:42.480
Increase the value and you can see the aid now is becoming more and more bright and more intensity,

04:42.670 --> 04:52.800
and then I turn it back low intensity so I can just that the brightness I want directly from the bottom

04:52.890 --> 04:53.100
of it.

04:53.310 --> 04:55.650
And as you can see, it's currently walking.

05:01.130 --> 05:07.550
And you can see here also the results on tinkered with the simulation, so I have just the exact same

05:07.550 --> 05:11.810
code we used for the activity and studied the simulation.

05:11.840 --> 05:15.380
Now, here's the potential, a look at the energy here.

05:15.410 --> 05:17.210
So the conundrum is at the minimum.

05:17.250 --> 05:25.750
Now I'm going to turn it all the way up and you can see the energy, the in and the energy laid out.

05:27.020 --> 05:30.510
So it's working just as with the real secrets and.

05:30.510 --> 05:31.640
Well, congratulations.

05:31.640 --> 05:33.380
That is the end of the activity.
