Control LED or AC bulb using ESP32 Built-in Touch pins
Control LED or AC bulb using ESP32 Builtin Touch
This this video how to use Capacitiv touch features of ESP32 WiFi, Bluetooth Microcontroller baord.
- 00:40 Introduction
- 03:02 Wiring Explained
- 06:25 Code Explained
- 09:26 LED turned ON/OFF with Touch
- 11:28 AC Bulb turned ON/OFF
- ESP32 Github repository
- ESP32 Datasheet (pdf)
- Robojax Arduino Course on Udemy
- Get Early Access to my videos via Patreon
Arduino Code
/*
* ESP32 Touch usage to control AC bulb or LED
*
* Written by Ahmad Shamshiri at 17:27
* in Ajax, Ontario, Canada.
* www.Robojax.com
* Watch video instruction for this:
* https://youtu.be/S45upZ836vA
*
* 10 touch pins. The pins are GPIO pins.
* T0 is pin 4
* T1 is pin 0
* T2 is pin 2
* T3 is pin 15
* T4 is pin 13
* T5 is pin 12
* T6 is pin 14
* T7 is pin 27
* T8 is pin 32
* T9 is pin 33
/*
*
*
* www.Robojax.com
*
Get this code and other Arduino codes from Robojax.com
Learn Arduino step by step in structured course with all material, wiring diagram and library
all in once place. Purchase My course on Udemy.com http://robojax.com/L/?id=62
If you found this tutorial helpful, please support me so I can continue creating
content like this. You can support me on Patreon http://robojax.com/L/?id=63
or make donation using PayPal http://robojax.com/L/?id=64
* * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been download from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const int touchPin = T0;
const int relayPin = 23;
const int sensitivity = 50;// watch video for details
void setup()
{
pinMode(relayPin, OUTPUT);
Serial.begin(115200);
delay(1000); // give me time to bring up serial monitor
Serial.println("Robojax");
Serial.println("ESP32 Touch Test");
Serial.println(1);
delay(1000);
Serial.println(2);
delay(1000);
Serial.println(3);
delay(1000);
Serial.println("Touch the touch pin");
}
void loop()
{
int touchValue =touchRead(touchPin);// get value using T6
Serial.print("Value:");
Serial.println(touchValue);
if(touchValue <= sensitivity)
{
Serial.print("Touched:");
digitalWrite(relayPin, HIGH);// turn ON Relay
}else{
digitalWrite(relayPin, LOW);// turn ON OFF
}
delay(300);
}