Skip to content

Instantly share code, notes, and snippets.

@greed9
Last active July 1, 2025 14:04
Show Gist options
  • Save greed9/cd82f1e99f3bac69d01be62af3287d2e to your computer and use it in GitHub Desktop.
Save greed9/cd82f1e99f3bac69d01be62af3287d2e to your computer and use it in GitHub Desktop.
Arduino touch switch using the Touchy library
// Arduino "No hardware" touch switch
// Based on https://github.com/todbot/TouchyTouch
#include "TouchyTouch.h"
#define STATUS_LED 4
#define SENSE_PIN 12
const int touch_pin = SENSE_PIN;
// Install as TouchyTouch library in Arduino.
TouchyTouch touches ;
void setup() {
Serial.begin(115200);
Serial.println("TouchyTouch simpletest");
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\n" ));
pinMode(STATUS_LED, OUTPUT);
// Initialize Touch button
touches.begin( touch_pin );
}
void loop() {
touches.update();
if ( touches.touched() ) {
Serial.print("Pin touched ");
digitalWrite(STATUS_LED, HIGH);
}
delay(10);
digitalWrite(STATUS_LED, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment