1
00:00:00,510 --> 00:00:07,590
Now that we are done with the LED blinking example, let's move on to the touch sensor example.

2
00:00:10,070 --> 00:00:15,410
This is a new cool feature that's available on the ESB 32 balls.

3
00:00:15,980 --> 00:00:20,660
VSP 32 has internal 14 internal capacitive touch sensors.

4
00:00:21,120 --> 00:00:24,980
We already explained or showed these pins.

5
00:00:29,720 --> 00:00:31,820
We already showed.

6
00:00:35,980 --> 00:00:41,190
Will explain this bends and the wiring layout of the speaker to to listen.

7
00:00:41,760 --> 00:00:44,520
But let's talk about them again now.

8
00:00:44,940 --> 00:00:52,590
These thin antenna capacitive touch sensors can be used as buttons, and there are numbers from general

9
00:00:52,590 --> 00:01:05,400
purpose input output number four zero two, 12, 13, 14, 15, 23 or 32, 33 and 27.

10
00:01:06,270 --> 00:01:10,940
These are the pins I will show you means no in a minute.

11
00:01:10,940 --> 00:01:11,300
OK?

12
00:01:14,250 --> 00:01:23,040
OK, this is it, and you can refer to the wiring layout or the pin diagram lesson where you can see

13
00:01:23,580 --> 00:01:24,330
these pins.

14
00:01:24,900 --> 00:01:30,960
These are 10 internal capacitive touch sensors that you can easily use.

15
00:01:31,950 --> 00:01:40,990
In order to leave these pins, what you need to do is use the function touch read, and this function

16
00:01:40,990 --> 00:01:51,250
will take only one variable, which is basically this is the function that usually takes one variable,

17
00:01:51,250 --> 00:01:57,550
which is the pin number, the symbol, number four, number five, and so on.

18
00:01:58,710 --> 00:01:59,160
So.

19
00:02:00,840 --> 00:02:06,360
In order to use this function first, we need to assign a variable.

20
00:02:08,070 --> 00:02:12,960
Now we can't right and value.

21
00:02:19,480 --> 00:02:21,040
And I touch read.

22
00:02:24,630 --> 00:02:30,900
Inside that, we call out any number we can use general purpose Input-Output, for which basically the

23
00:02:30,900 --> 00:02:33,060
first touch sensor t0.

24
00:02:33,870 --> 00:02:37,170
And now let's create a code.

25
00:02:37,290 --> 00:02:44,320
Where do we read the state of this touch sensor and submit on the serial monitor to do this?

26
00:02:44,370 --> 00:02:46,380
First, you need to.

27
00:02:47,630 --> 00:02:53,860
Initialize the zero communication in the setup method, as you can see between these two curly parentheses,

28
00:02:54,740 --> 00:03:00,650
so what cereal dots begin

29
00:03:03,500 --> 00:03:09,720
and use any Mod. We can use 150000 200s.

30
00:03:10,130 --> 00:03:13,940
And let's add some delay to help it

31
00:03:17,030 --> 00:03:17,810
stabilize

32
00:03:22,520 --> 00:03:23,330
one second.

33
00:03:24,200 --> 00:03:24,680
Now.

34
00:03:25,820 --> 00:03:27,290
Let's try this nonsense.

35
00:03:27,410 --> 00:03:29,480
Let's try cereal, dot, print.

36
00:03:37,010 --> 00:03:38,390
Yes, beef as a tool.

37
00:03:42,220 --> 00:03:42,760
Touch.

38
00:03:47,850 --> 00:03:59,130
Just now we have to set the pin moment for us output, we want to use the LEDs as an indicator for the

39
00:03:59,130 --> 00:04:02,320
touch straight or touch sensor state.

40
00:04:03,150 --> 00:04:10,740
So we have pin number two, which has the lid and we need it as output.

41
00:04:13,470 --> 00:04:19,620
We also need to write a value and make sure that it equals zero.

42
00:04:21,000 --> 00:04:24,330
We want to make sure that the lid is off.

43
00:04:26,670 --> 00:04:30,300
To do so, we need to write the pin number and light law.

44
00:04:31,230 --> 00:04:40,170
Using this line, we are making sure that when the esports starts, it will make sure that that it is

45
00:04:40,170 --> 00:04:40,530
off.

46
00:04:41,010 --> 00:04:46,050
It will only turn on if there is touch all of the touch sensors on.

47
00:04:47,830 --> 00:04:55,510
OK, now what we need to do next is read the value Dutch read using Dutch read and stored up inside

48
00:04:55,510 --> 00:04:56,080
the value.

49
00:04:56,920 --> 00:05:05,800
Now we want to ask a question if the Dutch value is above or below a certain value, we can turn on

50
00:05:05,800 --> 00:05:06,640
or off than it.

51
00:05:09,120 --> 00:05:15,270
But before we do that, we can't simply print the touch, read or the value that we get from a speed

52
00:05:15,270 --> 00:05:19,080
sensor, which is the capacitive touch sensor on the serial monitor.

53
00:05:19,230 --> 00:05:30,020
So let's get let's do this serial dot print online and inside it.

54
00:05:30,030 --> 00:05:31,650
We need to place the value.

55
00:05:33,300 --> 00:05:38,520
After that, we can add a delay on second delay.

56
00:05:40,720 --> 00:05:42,670
Now, let's try combining our code.

57
00:05:45,030 --> 00:05:47,040
Let's store it inside.

58
00:05:51,150 --> 00:05:52,410
Our coding folder.

59
00:05:52,560 --> 00:05:53,430
It's called a touch

60
00:05:56,100 --> 00:05:57,080
screen example.

61
00:06:04,740 --> 00:06:06,030
OK, let's remove this.

62
00:06:09,930 --> 00:06:11,400
Now let's combine it again.

63
00:06:22,980 --> 00:06:24,640
OK, Duncan boiling.

64
00:06:24,780 --> 00:06:28,410
Now let's upload the code to our ISP board.

65
00:06:48,020 --> 00:06:56,060
By the way, you can use number four, which is the pin number, or you can use t0 do you 182 up to

66
00:06:56,060 --> 00:07:02,450
210 because we already mentioned that we have, uh, 10 touch sensors.

67
00:07:04,130 --> 00:07:06,260
Now let's open up the serial monitor.

68
00:07:07,790 --> 00:07:08,040
OK.

69
00:07:08,120 --> 00:07:12,560
As you can see, that much value here is hundreds.

70
00:07:14,320 --> 00:07:19,540
And seven, and if we did touch it, it will change.

71
00:07:19,840 --> 00:07:20,730
Let me do that.

72
00:07:22,410 --> 00:07:28,830
OK, now, as you can see, we have 74, 37, 71, 70.

73
00:07:28,860 --> 00:07:30,330
Now let me touch the bin.

74
00:07:33,710 --> 00:07:39,680
As you can see, once I touched up in the values of goal below then.

75
00:07:41,650 --> 00:07:42,820
And when I leave it.

76
00:07:44,080 --> 00:07:47,290
Goes again up to seventy seven to two.

77
00:07:47,860 --> 00:07:51,970
So I think that we have a consistent value here.

78
00:07:52,030 --> 00:07:56,110
If the value is below 50 means that I'm touching the pain.

79
00:07:56,470 --> 00:08:00,070
If it is above 50 means that I'm not touching the pin.

80
00:08:00,190 --> 00:08:02,620
We can adjust our code accordingly.

81
00:08:02,740 --> 00:08:03,820
Now let's do that.

82
00:08:05,790 --> 00:08:07,650
Now let's go here.

83
00:08:07,770 --> 00:08:18,270
And if statement now in that statement, we are going to ask a question, the value is above.

84
00:08:19,680 --> 00:08:22,020
Or equal 50.

85
00:08:24,180 --> 00:08:26,100
And it's more of this side, these.

86
00:08:27,380 --> 00:08:32,210
So she is now in that case, we need to turn on the red.

87
00:08:36,570 --> 00:08:38,250
And add a delay.

88
00:08:41,080 --> 00:08:41,590
Ms.

89
00:08:46,630 --> 00:08:48,340
If the value is.

90
00:08:50,480 --> 00:08:51,470
Below 50,

91
00:08:54,500 --> 00:08:55,130
we need.

92
00:08:57,700 --> 00:08:58,900
To turn that off.

93
00:09:04,490 --> 00:09:06,770
OK, now let's verify our code.

94
00:09:13,220 --> 00:09:21,110
Oh, and let's print a sentence, and so these two statements using the serial print.

95
00:09:22,430 --> 00:09:26,870
So he is going to print lead on.

96
00:09:32,110 --> 00:09:36,040
And he is going to try and let off.

97
00:09:38,590 --> 00:09:40,150
Let's verify the court again.

98
00:09:51,130 --> 00:09:57,430
OK, now let's applaud, according to the SB 32 board again.

99
00:09:58,300 --> 00:10:00,130
The process takes some time.

100
00:10:05,040 --> 00:10:07,620
Now it's connecting to the board.

101
00:10:09,450 --> 00:10:11,310
Now it's writing the code.

102
00:10:11,670 --> 00:10:13,090
OK, done uploading.

103
00:10:13,110 --> 00:10:17,790
Now, if we open up the serial monitor, as you can see, the light is on.

104
00:10:18,630 --> 00:10:23,460
And if you take a look to your board, you can see that the lid is on.

105
00:10:25,190 --> 00:10:33,620
Now, let me touch the Touch Pen, as you can see, the value goes below 50 and the lid is off.

106
00:10:37,930 --> 00:10:38,500
That's it.

107
00:10:38,800 --> 00:10:46,570
This is how easily you can use and adjust the touch sensor inside the SB 32 board.

108
00:10:46,720 --> 00:10:53,200
It's built in so you don't have to connect any extra components.

109
00:10:53,440 --> 00:10:58,060
This is how amazing it is and how easy it is to deal with this ball.

110
00:10:58,450 --> 00:11:02,020
If you have any questions regarding this pen, I'm here to help you.

111
00:11:02,590 --> 00:11:03,680
Thanks for watching this lesson.

112
00:11:03,700 --> 00:11:06,130
This is Usha from educational engineering team.
