WEBVTT

00:00.150 --> 00:06.240
This is the step 11 and also the final step of the final project of this course.

00:06.530 --> 00:12.660
So the last thing we want to do now in our project is to use the photoresistor to get the current light.

00:12.660 --> 00:18.150
And with that current light and the current luminosity, what we are going to do is to so we are going

00:18.150 --> 00:21.600
to put on the green energy what we can call the light.

00:22.470 --> 00:30.240
And we are also going to add a new mode to the LCD screen so we can print the current value of the luminosity.

00:30.540 --> 00:32.040
So this can be useful.

00:32.340 --> 00:34.120
This is an added functionality.

00:34.200 --> 00:36.170
Get to the circuit and the project.

00:36.630 --> 00:37.690
This can be useful.

00:37.710 --> 00:43.260
Let's say you have the robots and you detect that when the light is too low, then you are going to

00:43.440 --> 00:46.910
automatically increase the light with some energies.

00:46.920 --> 00:52.320
For example, just like you will have automatic lights on a car and not also here.

00:52.320 --> 00:57.070
Not to confuse, but the ultrasonic sensor on the photoresistor are two different things.

00:57.090 --> 01:03.450
OK, the light that you set with the photoresistor will not help the ultrasonic sensor because the ultrasonic

01:03.450 --> 01:08.060
sensor will send some ways that do not require any light.

01:08.070 --> 01:13.890
OK, so the light here is just to say, OK, let's use some light so we can see the robot, let's use

01:13.890 --> 01:14.400
some light.

01:14.420 --> 01:16.800
So, well, let's see if you have a camera.

01:16.800 --> 01:23.430
If you add a camera in the robot, you can also help the camera by providing a good lighting.

01:23.610 --> 01:23.870
All right.

01:23.880 --> 01:25.120
So let's get started with this.

01:25.150 --> 01:31.770
So first, I am going to set up the photoresistor and let's put so we have all been here.

01:31.770 --> 01:32.700
Let's put it here.

01:33.210 --> 01:40.680
For example, define for to operate the store pin, which is a zero.

01:41.790 --> 01:50.940
And I'm going also to define here the light and pin pin number 10, make sure this is a pin which has

01:50.940 --> 01:53.340
a B.W. and functionality.

01:54.690 --> 02:02.400
So here we go in the set up in the set that we don't need to initialize the European because we are

02:02.400 --> 02:12.470
going to use it as an analog inputting, but we need to initialize spin mode like editing to output.

02:13.500 --> 02:14.940
Let's actually put that.

02:16.210 --> 02:18.430
With the other hand, it is here.

02:20.120 --> 02:28.970
OK, that's it for the initialization now in the loop, so we have our different functions, so we need

02:28.970 --> 02:35.900
to ask ourselves, do we want to only check the photoresistor when the application is locked or when

02:35.900 --> 02:37.220
the application is not locked?

02:37.220 --> 02:41.440
Or in any case and actually it doesn't really matter.

02:41.450 --> 02:42.700
Any case is fine.

02:42.740 --> 02:49.070
We just want to continuously check the photoresistor, but actually with the rate of one hundred milliseconds.

02:49.070 --> 02:55.690
So every 100 means we are going to update the light and update the LCD screen.

02:56.510 --> 02:57.470
So I'm going to add.

02:58.490 --> 03:09.830
OK, here we have I can if you up to the storm and cyclone last time.

03:12.050 --> 03:14.840
That's the last thing, right, Luminosity?

03:16.630 --> 03:24.640
Initialized to Amelie's and then unsigned long, let's see, breed luminosity.

03:26.070 --> 03:29.100
DeLay is so let's say one hundred.

03:30.310 --> 03:31.220
That would be fine.

03:31.630 --> 03:32.260
OK.

03:32.290 --> 03:39.750
Now in the loop, so I'm going to do I'm going to go at the end of the loop after we do everything OK,

03:39.760 --> 03:42.090
because it doesn't really matter.

03:42.520 --> 03:47.320
I'm going to do if thank no minus last time.

03:47.800 --> 03:48.240
Great.

03:49.470 --> 03:52.530
Luminosity, if this is greater than the.

03:53.570 --> 03:55.490
Great luminosity.

03:58.180 --> 03:58.690
Delate.

04:01.180 --> 04:07.270
What we do is always we add the delete to the last time.

04:09.670 --> 04:12.820
And now we can get so into luminosity.

04:14.470 --> 04:16.990
We can directly get the remnants with analog.

04:18.320 --> 04:21.520
Read from the photo register.

04:26.100 --> 04:28.200
And then we are going to do two things.

04:29.490 --> 04:33.810
Set light green on city.

04:34.410 --> 04:37.190
So let's create two functions to do that.

04:37.400 --> 04:44.040
I'm going to create in here above the void setup to void, let's say set light.

04:45.790 --> 04:49.210
Read from Luminosity.

04:50.850 --> 04:59.280
Within the INS, because this is a value between zero and one thousand twenty three, and I'm going

04:59.280 --> 05:05.520
to compute the brightness flexibile because the brightness for the analog verite function will be between

05:05.520 --> 05:08.730
zero and 255 brightness.

05:09.950 --> 05:20.870
Is equal to so we have already done that before, 255 minus luminosity divided by four, because we

05:20.870 --> 05:27.430
need to scale down the value from one cell twenty three maximum to two hundred fifty five maximum.

05:27.440 --> 05:31.890
So we need basically to divide by four and we need to also invest.

05:32.180 --> 05:37.070
OK, so the more luminosity, the lower the brightness.

05:38.500 --> 05:48.160
And then unallowed bright light and then so that's why I told you it's important to use a pillow U.N.

05:48.160 --> 05:50.440
team because we use analogue, right?

05:51.580 --> 05:52.120
Brightness.

05:54.270 --> 06:07.010
OK, we have the first function here and let's create another one void print luminosity on LCD int it.

06:09.010 --> 06:14.860
And actually, to print that on the screen, we need to check two things we need to check if this is

06:14.860 --> 06:16.410
not logged.

06:16.430 --> 06:26.440
So if exclamation mark is locked and if the LCG mode is actually the mode for the luminosities.

06:26.440 --> 06:30.040
So we need to create a new mode for the luminosity.

06:31.540 --> 06:34.160
So let's create here.

06:34.660 --> 06:43.630
We have LCD distending settings and different LCD mode, luminosity to.

06:45.140 --> 06:49.040
OK, so let's use that now to just.

06:50.110 --> 06:55.190
It if the mood is luminosity and then we're going to go out to toggle it.

06:56.470 --> 07:02.410
So if it's locked, we don't bring that, we print that warning, the error message, if it's not locked

07:02.410 --> 07:11.500
and the mode is the correct mode, we print the LCD set ghiorso zero zero.

07:13.610 --> 07:14.990
And Brent.

07:16.290 --> 07:17.130
Luminosity.

07:19.080 --> 07:31.110
And then actually print up the viral value we have it let's add a few extra species just in case.

07:32.530 --> 07:39.190
All right, so we should have the 16 characters and that's it for the two functions, so I'm going to

07:39.190 --> 07:41.740
call them from the look.

07:42.840 --> 07:49.650
A satellite with luminosity that we get here and.

07:50.600 --> 07:54.800
Let's go back to Princeton University and City.

07:58.540 --> 08:00.310
We luminosity.

08:02.860 --> 08:04.280
Let's not forget the semicolon.

08:05.110 --> 08:06.080
So what do we do here?

08:06.100 --> 08:10.180
We get the city, we set the light and we print on the LCD.

08:10.180 --> 08:13.840
And of course, when we go to this auction, we check the vault.

08:14.110 --> 08:16.950
So now we need to change the LCD mode.

08:16.960 --> 08:24.490
We need to add to handle this mode or so when we do the toggle LCD screen.

08:25.030 --> 08:25.330
OK.

08:26.380 --> 08:31.810
So we have case distance settings and in case.

08:33.680 --> 08:34.370
Luminosity.

08:36.240 --> 08:38.710
So you can see now why I used the switch.

08:39.290 --> 08:41.790
Let's just break and let's do.

08:43.010 --> 08:46.370
Entity mode is now equal to.

08:50.570 --> 08:52.860
And here I'm going to put it here.

08:53.630 --> 08:58.820
So if his distance would change to settings, if it's settings would change to a living entity, if

08:58.820 --> 09:01.590
it's luminosity would change to distance again.

09:02.760 --> 09:04.230
And the thing is that No.

09:05.590 --> 09:11.560
As you can see here, we have to balance, we are up and down, so before that, it was not that important

09:11.560 --> 09:18.260
because we only had two votes, but now we have mode's one, two and three, which means that Wildeblood

09:18.330 --> 09:23.760
that we could say we want to go to the next move and with the Burrendong, we want to go to the previous

09:23.760 --> 09:24.110
smoke.

09:24.130 --> 09:29.080
So if you're in mode two, for example, and you press the button up, you go to three.

09:29.770 --> 09:32.630
But if you press the button down, you go to mode one.

09:33.820 --> 09:36.370
So let's add here, let's make it simple.

09:36.370 --> 09:38.950
Let's add a boolean next.

09:40.060 --> 09:43.750
If the boolean is true, it means the next one.

09:43.780 --> 09:46.650
If the word is false, it means the previous one.

09:47.320 --> 09:49.440
So not in the mood is currently distance.

09:49.450 --> 09:53.650
What I'm going to do, I'm going to use the one line if next.

09:55.060 --> 09:56.390
So next is a boolean.

09:56.410 --> 09:58.630
So this we can just test it.

09:58.630 --> 10:00.490
OK, three, be true or false.

10:00.970 --> 10:06.040
If next then we go to sitting's and then Calon.

10:06.340 --> 10:11.480
If not, we go to Leninists, which is the mode number three.

10:11.740 --> 10:16.390
So when we are in mode, the first mode next we go to the second mode.

10:16.690 --> 10:18.570
Previous we go to the mode.

10:18.580 --> 10:27.680
So the last one OK then aelfwine mode settings and we have the next, next, then we go to Luminosity.

10:28.120 --> 10:30.670
But if it's previous we go to distance.

10:32.040 --> 10:34.950
And then when we are in Luminosity, if.

10:36.470 --> 10:41.910
Next, then we go to distance, OK, because there is nothing after leaving the city, we go back to

10:41.930 --> 10:42.380
distant.

10:43.560 --> 10:47.630
Else, we go back to settings here.

10:49.330 --> 10:55.150
OK, and you can see now you can add as many GS as you want in the switch, that would be very easy

10:55.150 --> 10:55.690
to handle.

10:55.720 --> 11:01.540
OK, just do next and then the next one, the previous one you can choose in which order you are going

11:01.540 --> 11:05.220
to navigate through the different modes of the exit.

11:05.620 --> 11:11.470
And of course, the default is always going to the default in case we have said something that is wrong.

11:11.680 --> 11:15.940
And because we have moved next, now we need to actually use.

11:17.490 --> 11:18.160
A perimeter.

11:18.630 --> 11:25.800
That's where we have an arrow, something to do through here and force him to go LCD screen through

11:25.800 --> 11:29.220
for next Fox for next, which means produce one.

11:29.820 --> 11:30.480
All right.

11:30.480 --> 11:39.980
Let's just verify and name it as final projects that even the last one.

11:42.920 --> 11:45.130
Don't complaining and no.

11:45.740 --> 11:54.200
So just a very quick recap of what we have added here, so we have added the photoresistor reading here,

11:54.210 --> 11:55.180
we finally agreed.

11:55.400 --> 12:02.270
We also the time functionality to read every one hundred milliseconds, which should be here.

12:03.560 --> 12:12.080
And then what we do is we set light energy, so we use analogue right for the energy to increase the

12:12.080 --> 12:19.820
brightness when the luminosity decreases and then we print the luminosity on the LCD when we are in

12:19.820 --> 12:22.520
the LCD mode, luminosity.

12:22.700 --> 12:29.900
And of course, because we have added one mode, we have added this mode also to the toggle LCD screen

12:29.900 --> 12:30.590
function.

12:30.670 --> 12:36.680
OK, so we can toggle between the different modes using two older going to the next one, all the previous

12:36.680 --> 12:43.070
one from the button up and down from the infrared remote control.

12:43.310 --> 12:49.090
So now you can see once you have set up the different functionalities and components, you can create

12:49.090 --> 12:53.640
a much more complex behavior and you don't need to write thousands of lines of code.

12:54.020 --> 12:59.590
And now let's finally upload that, which is the final product, which is the complete project.

13:00.110 --> 13:03.350
And let's see if everything is working.

13:04.970 --> 13:10.910
So you can see here we have the distance in centimeters and now I'm going to press on down button.

13:11.510 --> 13:15.740
So I'm going to the settings, which is the next mode I press again.

13:15.980 --> 13:23.810
I go on the luminosity and I can see the luminosity as well as the energy here, which is both on OK.

13:24.770 --> 13:31.520
And if you try to lower that immunity, you will see the brightness increase and you increase the luminosity,

13:31.520 --> 13:32.820
the brightness will decrease.

13:33.200 --> 13:35.440
So no angle in that order.

13:35.450 --> 13:44.330
So distance settings, Leninists and going to the other down button and I'm going under the reverse

13:44.330 --> 13:44.710
order.

13:44.870 --> 13:48.590
OK, luminosity settings, distance.

13:49.850 --> 13:50.240
OK.

13:51.900 --> 13:57.360
And well, sometimes it may happen that it's too sensitive, so you are going to press twice on the

13:57.360 --> 14:01.890
same button, so just make sure that you correctly press on the button.

14:02.080 --> 14:07.620
And, of course, again, that you have a good battery inside the remote control and, well, that is

14:07.620 --> 14:09.480
the end of the final project.
