Project tutorial
touch sensor

touch sensor

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

  • 19,126 views
  • 4 comments
  • 12 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 Sensor and Sound Sensor Controlling AC/DC Lights

Project showcase by Anbumachi

  • 1,160 views
  • 2 comments
  • 5 respects

Touch Controlled Light Using Arduino

Project tutorial by Amal Mathew

  • 4,004 views
  • 2 comments
  • 11 respects

eNVIRO: 7" Touch Panel Weather Station with Remote Sensor

Project in progress by antiElectron

  • 3,529 views
  • 1 comment
  • 12 respects

Grove Starter Kit for Arduino: Touch sensor

by Grant

  • 717 views
  • 1 comment
  • 2 respects

Vibration Sensor Module

Project tutorial by Alberto Zanon

  • 21,186 views
  • 2 comments
  • 9 respects

Hall effect sensor with Arduino

Project tutorial by AMAL NS

  • 9,420 views
  • 1 comment
  • 22 respects
Add projectSign up / Login