In this lecture, I'll show you how to use the range note this one right here on the function.
So the range notice is like the map function in the original programming language.
It takes a number which belongs to a particular scale or range, and it will map it into a new number
in a new range.
So in this example here, I've got this scale node that takes in a number that belongs in the range
of zero to one thousand twenty three.
This could be perhaps an analog input in Dwinell and then it will convert that into a number that belongs
in a range between zero and one hundred.
It's just mapping.
You can choose these three options as well as to how you'd like this mapping to take place of going
full scale and limit it to the target range.
All right.
So for input, I'm just typing in a number and then for the output showing both the raw input and the
scaled output or scaled number.
All right, deploy that.
And let's start with maxed out 1020 through to the top of the range.
And 1023 becomes one hundred, what about, say, five hundred?
For the input deploy and five hundred becomes forty eight point eighty seven, I can around this to
an integer if I don't want to have the decimals and that now would look like this.
Five hundred becomes forty nine if I go beyond the scale.
So let's say I make that one thousand five hundred.
Let's see what happens.
It still comes in as one thousand five hundred, but the output is at the max one hundred of the range,
and I suspect the same thing is going to happen if I go for a valley below the bottom end of the input
range.
So that's a zero.
All right, so this is very useful, especially when you work with numbers that have limited input and
a limited output and they are numbers in different ranges.
And I'll be using this in our project to scale the analog input that comes from the E.S.P 32 for the
humidity of the soil into a number from zero to one hundred and three percent humidity in terms of percentage.