In this new activity, you are going to do something a little bit different with your photoresistor
senseor and let's say a little bit more scientific.
So when you have a sensor that gives you some values or photoresistor temperature sensor or put on Schmitter,
a ultrasonic distance sensor, whatever, so it can be interesting to know not only what values you
get from the sensor, but what is the average value you get over a certain period of time.
So, for example, for the photoresistor sensor, you might put it somewhere and compute the average
luminosity you get over 24 hours.
OK, for example, of a one hour of whatever period of time you want.
So to do that, what you need to do is to read some data from the sensor every X amount of time that
you define and each reading, we are going to call that a sample.
So you are going to save those samples inside an array and after a certain period of time, you are
going to compute the average of these three.
So this doing this can be very useful to do some measurements of your environment.
So what you are going to do in this activity, you are going to get some simple so gets simpler.
So it gets luminosity simple.
Simple every 50 milliseconds.
OK, four, five, six.
So actually, that's one hundred samples.
Of course, I'm not going to make the example for twenty four hours because the twenty four hour video
will be quite boring.
But let's use this for one hundred samples that we take every 15 minutes.
OK, and then those two parameters, you can just modify them as you want.
And then so when you have those one hundred samples you are going to compute the average.
So to compute the average, if you don't know the formula.
The formula is very simple.
You take the sum of all values and you divide that by the number of values.
So for one hundred samples, you make the sum of all the elements in the array and you divide it by
one hundred.
And so what you're going to do is you're going to print.
So you're going to measure that, OK, in 15 milliseconds using the time functionality, of course,
and not delay.
And then after you get one hundred samples, you compute the average and you print print the average.
So here you are going to need to use arrays, function and the average computation here.
All right.
And I will see you in the next lesson folder solution.