Код для поиска

Control LED or AC Bulbs Using ESP32 Built-in Touch Pins

Control LED or AC Bulbs Using ESP32 Built-in Touch Pins

This video shows how to use capacitive touch features of the ESP32 WiFi, Bluetooth microcontroller board.

Изображения

Arduino Code
Arduino Code
245-Arduino code
Язык: C++
/*
 * ESP32 Touch usage to control an AC bulb or LED
 * 
 * Written by Ahmad Shamshiri at 17:27
 * in Ajax, Ontario, Canada. 
 * www.Robojax.com
 * Watch video instructions 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 a structured course with all material, wiring diagrams, and libraries
all in one 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 a 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 downloaded 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 OFF Relay      
  }
  delay(300);
}

Ресурсы и ссылки

Ресурсов пока нет.

Файлы📁

Нет доступных файлов.