Touch

The Touch Sensor is sensitive to skin contact.

Input: This module normally outputs 0v, but when touched, sends 5v. When connected to an input on the Arduino using the TinkerKit Shield, you will see 0 when there is no touch, and 1023 when touched.

Module Description: on the back of the module you can find a signal amplifier, a capacitor, a QT 100A single touch controller, a green LED that signals that the module is correctly powered and a yellow LED whose brightness depends on the values output by the module.

Please note this device performs an auto calibration when it is turned on, so if someone is touching the switch surface when it’s turning on, it won’t work. To reset it, cycle power and make sure no one is touching it as you restart.

TKTouchSensor touch(I0);

Available methods

read() return the touch sensor reading. HIGH if is pressed, LOW if is released
pressed() trigger the instant when the touch sensor is being pressed and return the HIGH value
released() trigger the instant when the touch sensor is being released and return the HIGH value
held() this method compares the state of the touch sensor with the previous one and return HIGH if is held
readSwitch() with this method the touch sensor acts like a switch. Each press change the return value, that can be HIGH or LOW

 

// include the TinkerKit library
#include <TinkerKit.h>

// creating the object 'touch' that belongs to the 'TKTouchSensor' class 
TKTouchSensor touch(I0);

// creating the object 'led' that belongs to the 'TKLed' class 
TKLed led(O0);		

void setup() {
  //nothing here
}

void loop()
{
  // check the "switch state" of the sensor
  // if it is, turns on the LED
  if (touch.readSwitch() == HIGH) {      
    led.on();     // turn LED on 
  } else {
    led.off();    // turn LED off
  }
}