WEBVTT

00:00.210 --> 00:05.610
In this new activity, you are going to do something a little bit different with your photoresistor

00:05.610 --> 00:08.680
senseor and let's say a little bit more scientific.

00:09.060 --> 00:15.980
So when you have a sensor that gives you some values or photoresistor temperature sensor or put on Schmitter,

00:16.050 --> 00:23.910
a ultrasonic distance sensor, whatever, so it can be interesting to know not only what values you

00:23.910 --> 00:29.580
get from the sensor, but what is the average value you get over a certain period of time.

00:30.390 --> 00:36.360
So, for example, for the photoresistor sensor, you might put it somewhere and compute the average

00:36.420 --> 00:39.040
luminosity you get over 24 hours.

00:39.110 --> 00:43.890
OK, for example, of a one hour of whatever period of time you want.

00:44.100 --> 00:50.760
So to do that, what you need to do is to read some data from the sensor every X amount of time that

00:50.760 --> 00:55.180
you define and each reading, we are going to call that a sample.

00:55.200 --> 01:01.110
So you are going to save those samples inside an array and after a certain period of time, you are

01:01.110 --> 01:03.530
going to compute the average of these three.

01:03.900 --> 01:09.700
So this doing this can be very useful to do some measurements of your environment.

01:10.320 --> 01:15.690
So what you are going to do in this activity, you are going to get some simple so gets simpler.

01:15.690 --> 01:17.460
So it gets luminosity simple.

01:19.240 --> 01:23.160
Simple every 50 milliseconds.

01:23.800 --> 01:27.140
OK, four, five, six.

01:27.670 --> 01:30.550
So actually, that's one hundred samples.

01:31.180 --> 01:36.850
Of course, I'm not going to make the example for twenty four hours because the twenty four hour video

01:36.880 --> 01:38.380
will be quite boring.

01:38.590 --> 01:42.730
But let's use this for one hundred samples that we take every 15 minutes.

01:43.210 --> 01:48.210
OK, and then those two parameters, you can just modify them as you want.

01:48.400 --> 01:53.970
And then so when you have those one hundred samples you are going to compute the average.

01:54.370 --> 01:57.610
So to compute the average, if you don't know the formula.

01:57.620 --> 01:58.920
The formula is very simple.

01:58.930 --> 02:05.410
You take the sum of all values and you divide that by the number of values.

02:05.590 --> 02:11.900
So for one hundred samples, you make the sum of all the elements in the array and you divide it by

02:12.040 --> 02:12.660
one hundred.

02:13.150 --> 02:15.680
And so what you're going to do is you're going to print.

02:15.700 --> 02:22.930
So you're going to measure that, OK, in 15 milliseconds using the time functionality, of course,

02:22.930 --> 02:23.730
and not delay.

02:23.950 --> 02:32.200
And then after you get one hundred samples, you compute the average and you print print the average.

02:35.560 --> 02:41.500
So here you are going to need to use arrays, function and the average computation here.

02:41.770 --> 02:42.190
All right.

02:42.200 --> 02:45.400
And I will see you in the next lesson folder solution.
