Now that we are done with the little blinking example, let's move on to the touch sensor, for example.
This is a new cool feature that's available on the E.S.P 32 bawls, VSP 32 has internal alten, internal
capacitive touch sensors.
We already explained or showed the spin's.
We already showed.
Well, the exit plan depends on the wiring layout of the speaker to listen, but let's talk about them
again now.
These eastern antenna capacitive touch sensors can be used as buttons.
And there are numbers from general-purpose and what output?
Number four zero to 12, 13, 14, 15 at 23 or 32, 33 and 27.
These are the pens.
I will show you the bends number in a minute, OK?
OK, this is it.
And you can refer to the wiring layout or the pin diagram lesson where you can see these pins.
These are 10 internal capacitive touch sensors that you can easily use in order to read these pins.
What you need to do is use the function touch.
Right.
And this function will take only one variable, which is basically this is the function and it usually
takes one variable, which is the PIN number, the serial number four, number five and so on.
So.
In order to use this function first, we need to assign a variable.
Now we can write int value.
And right touch Reed
inside that vehicle, like any number, we can use that purpose input output for which basically the
first touch since Sorte zero.
And now let's create a code where we read the state of this touch sensor and submit on the Syrian monitor
to do this.
First, you need to.
Initialize the communication in the setup method, as you can see, between these two curly parentheses.
So right serial dot begin
and use and what rate we can use one hundred fifteen thousand two hundred.
And let's add some delay to help with
stabilize.
One second now.
Let's try this nonsense, let's try serial, not print.
Yes, be fair to.
Touch
this now we have to set the mood for the US as output, we want to use the lid as an indicator for the
Dutch state or the Dutch since all state.
So we have been number two, which has the lid, and we need it as output.
We also need to write a value and make sure that it equals zero.
We want to make sure that the lid is off.
To do so.
We need to write the PIN number and write law.
Using this line.
We are making sure that when the E.S.P board starts, it will make sure that that it is off.
It will only be a loan if there is touch or if the touch sensors on.
OK, now what we need to do next is read the value, touch, read using touch, read and saw inside
the value.
Now we want to ask a question.
If the touch value is above or below a certain value, we can turn on or off the.
But before we do that, we can simply print that judge, read all the value that we get from the touch
screen sensor, which is the capacitive touch sensor on the Syrian monitor.
So let's get let's do this serial dot print online and inside it.
We need to place the value.
After that, we can add a delay on second delay.
Now, let's try combining our code.
Let's store it inside.
Our coding folder, it's called Touch Screen Example.
OK, let's remove this.
Now, let's come back again.
OK, done compiling now let's upload the code to our E.S.P board.
By the way, you can use number four, which is the PIN number, or you can use to zero to one, three
to up to T10, because we already mentioned that we have, uh, ten touch sensors.
Now, let's open up the serial monitor.
OK, as you can see, that much value here is 100.
And seven, and if we did touch it, it will change.
Let me do that.
OK, now, as you can see, we have a 74, 37, 71, 70.
Now let me touch that, Ben.
As you can see, once I touched upon the values goal below, then.
And when I leave it.
Goes again, up to seventy seven to two, so I think that we have a constant value here.
If the value is below 50, it means that I'm touching the pen.
If it is above 50 means that I'm not touching the pen, we can adjust our code accordingly.
Now, let's do that.
Now, let's go here and add if statement now and that statement, we are going to ask a question, the
value is, above all, equal 50.
And it's more this side, these.
So policy is now in that case, we need to turn on the red.
And Odelay.
Ms.
If the value is.
Below 50,
we need to turn the lid off.
OK, now let's verify our quote.
Oh, and let's print a sentence inside these 12 statements using the serial print.
So here we are going to print lead on.
And here we are going to present a lot of let's vilify the call again.
OK, now let's upload the code to the ISP circuit board again, the process takes some time.
Now it's connecting to the board.
Now it's writing the code.
OK, done uploading now if we open up the serial monitor, as you can see, the light is on and if you
take a look at your board, you can see that the lid is on.
Now, let me touch the touch pen, as you can see, the value goes below 50 and the lid is off.
That's it.
This is how easily you can use and adjust the touch sensor inside the E.S.P 32 ball.
It's built in so you don't have to connect any extra components.
This is how amazing it is and how easy it is to deal with this ball.
If you have any questions regarding this pin.
I'm here to help you.
Thanks.
Watching this.
Listen, this is from educational engineering team.