1
00:00:00,660 --> 00:00:06,510
In this lecture, I'll show you how to use the range note this one right here on the function.

2
00:00:06,870 --> 00:00:11,910
So the range notice is like the map function in the original programming language.

3
00:00:11,910 --> 00:00:20,640
It takes a number which belongs to a particular scale or range, and it will map it into a new number

4
00:00:20,640 --> 00:00:22,530
in a new range.

5
00:00:23,040 --> 00:00:30,840
So in this example here, I've got this scale node that takes in a number that belongs in the range

6
00:00:30,840 --> 00:00:32,820
of zero to one thousand twenty three.

7
00:00:33,180 --> 00:00:41,040
This could be perhaps an analog input in Dwinell and then it will convert that into a number that belongs

8
00:00:41,040 --> 00:00:42,870
in a range between zero and one hundred.

9
00:00:43,080 --> 00:00:44,070
It's just mapping.

10
00:00:44,850 --> 00:00:52,230
You can choose these three options as well as to how you'd like this mapping to take place of going

11
00:00:52,230 --> 00:00:54,750
full scale and limit it to the target range.

12
00:00:55,470 --> 00:00:55,930
All right.

13
00:00:55,950 --> 00:01:05,190
So for input, I'm just typing in a number and then for the output showing both the raw input and the

14
00:01:05,190 --> 00:01:07,980
scaled output or scaled number.

15
00:01:08,880 --> 00:01:10,230
All right, deploy that.

16
00:01:10,230 --> 00:01:14,640
And let's start with maxed out 1020 through to the top of the range.

17
00:01:15,940 --> 00:01:23,110
And 1023 becomes one hundred, what about, say, five hundred?

18
00:01:24,470 --> 00:01:34,310
For the input deploy and five hundred becomes forty eight point eighty seven, I can around this to

19
00:01:34,310 --> 00:01:41,420
an integer if I don't want to have the decimals and that now would look like this.

20
00:01:41,780 --> 00:01:45,880
Five hundred becomes forty nine if I go beyond the scale.

21
00:01:45,890 --> 00:01:48,680
So let's say I make that one thousand five hundred.

22
00:01:49,370 --> 00:01:50,480
Let's see what happens.

23
00:01:52,590 --> 00:02:00,150
It still comes in as one thousand five hundred, but the output is at the max one hundred of the range,

24
00:02:00,570 --> 00:02:08,490
and I suspect the same thing is going to happen if I go for a valley below the bottom end of the input

25
00:02:08,490 --> 00:02:09,060
range.

26
00:02:10,560 --> 00:02:11,670
So that's a zero.

27
00:02:12,240 --> 00:02:18,720
All right, so this is very useful, especially when you work with numbers that have limited input and

28
00:02:18,720 --> 00:02:22,340
a limited output and they are numbers in different ranges.

29
00:02:22,350 --> 00:02:31,230
And I'll be using this in our project to scale the analog input that comes from the E.S.P 32 for the

30
00:02:31,230 --> 00:02:38,790
humidity of the soil into a number from zero to one hundred and three percent humidity in terms of percentage.
