Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tessel 2 with Adafruit RGB TCS34725 sensor publishing data using socket.io
var tessel = require('tessel');
var rgbLib = require('rgb-tcs34725');
var rgb = rgbLib.use(tessel.port.A);
var server = require('http').createServer();
var io = require('socket.io')(server);
io.on('connection', function(socket){
console.log('new connection');
socket.on('event', function(data){});
socket.on('disconnect', function(){});
});
server.listen(3000);
rgb.on('ready', function() {
setInterval(function() {
rgb.getRawData(function(err, colors) {
if (err) throw err;
console.log('RED:', colors.red);
console.log('GREEN:', colors.green);
console.log('BLUE:', colors.blue);
console.log('CLEAR:', colors.clear);
io.emit('colors', colors);
})
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.