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