Skip to content

Instantly share code, notes, and snippets.

@rondagdag
Created November 30, 2015 21:12
Show Gist options
  • Save rondagdag/ab0754e877eb5b843654 to your computer and use it in GitHub Desktop.
Save rondagdag/ab0754e877eb5b843654 to your computer and use it in GitHub Desktop.
NodeJS application
var Cylon = require('cylon');
var Barcli = require("barcli");
var attentionGraph = new Barcli({
label: "attention Graph",
range: [0, 100],
});
var apiKey = '<Your API Key>';
var IFTTTMaker = require('iftttmaker')(apiKey);
var trigger_on = 'MindControlTrigger_On';
var trigger_off = 'MindControlTrigger_Off';
Cylon.robot({
connections: {
neurosky: { adaptor: 'neurosky', port: '/dev/cu.MindWaveMobile-DevA' }
},
devices: {
headset: { driver: 'neurosky' }
},
work: function(my) {
my.headset.on('attention', function(data) {
//Logger.info("attention:" + data);
if (data < 100)
{
attentionGraph.update(data);
if (data > 50)
{
IFTTTMaker.send(trigger_on, function (error) {
if (error) {
console.log('The request could not be sent:', error);
} else {
console.log('Request was sent');
}
});
} else
{
IFTTTMaker.send(trigger_off, function (error) {
if (error) {
console.log('The request could not be sent:', error);
} else {
console.log('Request was sent');
}
});
}
}
});
}
}).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment