No. A boolean variable can only have one of 2 states, either true or false. Greater than really has no meaning in the context of a boolean value
What
if (touchValue < lowerThreshold && currentlyTouched == false)
says in English is
"if the touch value is less than the lower threshold and the currently touched boolean variable is false then execute the code in the following code block"
ie, it tests whether the touch value has fallen below the lower threshold and it has not happened before, then execute the following code
Hmm Ya I gone through some with guidance from all you expertise here
As there are some kind of restrictions with analog type things on MCUs
So I am trying to sort out all those with number of ways
Well this newly generated code from your given basic code is working well for now
(Just a bit breadboard issues so values are varying time to time and need to fix)
So shall I now try to connect the touch read with different resistor values ?
Will it work on the same line or I need to go for other pins ?
Please guide and till the time I am planning for few more things to add !!
From memory, there are only 6 pins on the ESP32 that allow you to use the touchRead() function. If you want more touch input pads then you will need to use a different method such as analogRead() and a resistor ladder.
Be aware, however, that will quite probably not be reliable unless you use an external device, maybe the TTP223, on each pin. The ESP32 touch pins do not need any extra circuitry because they work differently
And I observed it practically one by one on trainer board
Though it is 10 but of no use as this one is engaging approx all the pins for further use like sensors or display devices and etc etc things !!!
Too I need 16 or 20 or may be more than 20 inputs here so a ladder pattern is all the way good !!!
Yes yes sure !
In case of resistor ladder, I will have to connect a touch sensor with a transistor switch and a reference resistor for a fixed value say 2000 or 2250 like that.
For more number of inputs in a single line the reference resistor value should be allotted wisely to get a bit big difference between 2 values as the range falls between 0 to 4096 something.
Suppose if it is not possible to adjust more that 10 inputs on single line then I need to switch for another input pin
Like pin 36 for 10 inputs
and pin 39 for 10 inputs
and so on . . . . . .