click here to enter

Touch sensor - Kingston hackSpace

Kingston hackSpace

Touch sensor

This breakout board is the simplest way to create a project with a single “momentary” touch sensor. When a capacitive load is detected (e.g. a person touches the sensor-pad area) the red LED lights up and the output pin goes high. You can also solder a wire to the middle pad and create your own capacitive pad if the built-in one isn’t suited to your project. However for additional contacts, I would suggest using copper foil, and then solder a wire that connects from the foil pad to the breakout.

Touch sensor

Arduino Pins

SIG

PIN D2

VCC

5V

GND

GND

 

The electronic structure of the touch sensor is very similar to touch board single electrode. Connections are every simple a positive up to 5V to VCC, GND to the negative (Ground) and the middle pin which will transfer a signal to our microcontroller any digital pins.

 


#define ctsPin 2 // Pin for capactitive touch sensor
 
int ledPin = 13; // Digital pin 13 for the LED
 
void setup() {
  Serial.begin(9600);  // Start serial monitor 
  pinMode(ledPin, OUTPUT);  
  pinMode(ctsPin, INPUT);
}
 
void loop() {
  int ctsValue = digitalRead(ctsPin); 
  // Assigning code responsible for detecting touch

  if (ctsValue == HIGH){  // If the sensor detect touch 
    digitalWrite(ledPin, HIGH);  // Turn the LED ‘ON’
    Serial.println(“Touched”);  // Print “Touched” in serial monitor
  }
  else{ // Otherwise
    digitalWrite(ledPin,LOW); // Turn the LED ‘OFF’
    Serial.println(“Not touched”); // Print “Not touched” in serial monitor
  } 
  delay(500);
}