Project tutorial
touch sensor

touch sensor

this project uses a touch sensor to turn on and off an led on pin 13.

  • 31,355 views
  • 5 comments
  • 13 respects

Components and supplies

Apps and online services

About this project

I wanted a reference for a touch sensor project I was doing, but there were none for my touch sensor, so I figured it would be like a button and found a tutorial for buttons, so I modified the code for my touch sensor.

Code

touch switch 1000Arduino
the modified code for a touch sensor.
int in = 2; 
int out = 13;  
int state = HIGH;  
int r;           
int p = LOW;    
long time = 0;       
long debounce = 200;   
void setup()
{
  pinMode(in, INPUT);
  pinMode(out, OUTPUT);
}
void loop()
{
  r = digitalRead(in);
  if (r == HIGH && p == LOW && millis() - time > debounce) {
    if (state == HIGH)
      state = LOW;
    else 
      state = HIGH;
    time = millis();    
  }
  digitalWrite(out, state);
  p = r;
}

Schematics

touch_sensor_ymqa8EeB5k.fzz
touch_sensor_ymqa8EeB5k.fzz

Comments

Similar projects you might like

Touch Less Touch Switch - A touch alternative UI

Project tutorial by Jithesh Thulasidharan

  • 3,233 views
  • 2 comments
  • 7 respects

Touch Sensor and Sound Sensor Controlling AC/DC Lights

Project showcase by Anbumachi

  • 6,329 views
  • 2 comments
  • 8 respects

Vibration Sensor Module

Project tutorial by Alberto Zanon

  • 78,307 views
  • 9 comments
  • 21 respects

HOW PIR SENSOR WORK

Project tutorial by DIY Partners

  • 17,575 views
  • 9 comments
  • 45 respects

Touch Controlled Light Using Arduino

Project tutorial by Amal Mathew

  • 22,623 views
  • 8 comments
  • 15 respects

eNVIRO: 7" Touch Panel Weather Station with Remote Sensor

Project in progress by antiElectron

  • 8,262 views
  • 4 comments
  • 25 respects
Add projectSign up / Login