Skip to content

Instantly share code, notes, and snippets.

@Atlas7
Last active October 17, 2015 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Atlas7/172ee78e083bbd979c27 to your computer and use it in GitHub Desktop.
Save Atlas7/172ee78e083bbd979c27 to your computer and use it in GitHub Desktop.
Hardware Project: Don't Tickle Me!

a Smart Alerting System leveraging Touch Sensor and LED. (Intel Edison Board, Arduino, Grove Touch Sensor and LED, Intel XDK IoT Edition IDE, NodeJS).

See this YouTube demo.

/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
// Leave the above lines for propper jshinting
//Type Node.js Here :)

// Board Setup
// D6: Grove TTP223 Touch Sensor
// D2: Grove LED Red

// Usage
// Touch the touch sensor, the LED gets turn on!

// Load TTP223 touch sensor module
var sensorModule = require('jsupm_ttp223');

// Load Grove module
var groveSensor = require('jsupm_grove');

// Create the TTP223 touch sensor object using GPIO pin 6
var touch = new sensorModule.TTP223(6);

// Create the Grove LED object using GPIO pin 2
var led = new groveSensor.GroveLed(2);

// Check whether or not a finger is near the touch sensor and
// print accordingly, waiting one second between readings
function readSensorValue() {
    if ( touch.isPressed() ) {
        //console.log(touch.name() + " is pressed");
        led.on();
    } else {
        //console.log(touch.name() + " is not pressed");
        led.off();
    }
}
setInterval(readSensorValue, 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment